Originalmente inviato da
andreafallico
Nel codice del microcontrollore.
nel codice del microcontrollore ???
questo è il codice:
Codice:
byte mac[] = {0x90,x,0xDA,0x00,x,0x99};
byte ip[] = {192,x,x,x};
byte gateway[] = {x, x, x, x};
byte subnet[] = {255, x, 255, 0};
char serverName[] = "www.xxxx.altervista.org";
EthernetClient client;
void setup() {
// start the serial library:
Serial.begin(9600);
Ethernet.begin(mac,ip,gateway,subnet);
delay(1000);
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect(serverName, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET /index.php?temperatura=22&&umidita=20 HTTP/1.0");
client.println();
}
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:
while(true);
}
}
Dove dovrei metterlo ?
Grazie ancora.