Rieccomi qui piantato -
Ora uso il codice fornito da Pitusso:
#include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {0x90,0xA2,0xDA,0x00,0x74,0x99};
byte ip[] = {192,168,1,2};
byte gateway[] = {192, 168, 1, 1};
byte subnet[] = {255, 255, 255, 0};
byte server[] = { 176, 9, 63, 22}; //altervista ip, risultato del ping ratto93.altervista.org
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
Client client(server, 80);
void setup() {
// start the Ethernet connection:
Ethernet.begin(mac,ip,gateway,subnet);
// start the serial library:
Serial.begin(115200);
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect()) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET /index.php?temperatura=22&umidita=22 HTTP/1.0"); //GET da effettuare
client.println("Host: ratto93.altervista.org"); //parametro Host per gestione virtual server
client.println(); //riga vuota
}
else {
// kf you didn't get a connection to the server:
Serial.println("connection failed");
}
}
void loop()
{
// if there are incoming bytes available
// from the server, read them and print them:
if (client.available()) {
char c = client.read();
Serial.print(c);
}
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
// do nothing forevermore:
for(;;)
;
}
}
Ma invece di visualizzare la pagina nel browser me la fa vedere nel serial monitor !?!
come mai ?
connecting...
connected
HTTP/1.1 200 OK
Content-Length: 211
Date: Mon, 06 Feb 2012 14:23:43 GMT
Server: Apache
Vary: Accept-Encoding
Content-Type: text/html
Connection: close
<HTML>
<HEAD>
<TITLE>Accesso al servizio</TITLE>
</HEAD>
<BODY>
<H2>Gestione accessi</H2>
<HR>
La temperatura attuale è di 22 °.
L'umidità è pari al %
alle ore15:23:43del giorno06-02-2012</BODY>
</HTML>
disconnecting.