#include <SPI.
h>
#include <Ethernet.h>
EthernetServer servidor(80); // puerto de conexión
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //mac address
byte ip[] = { 192, 168, 1, 205 }; // ip de tu Arduino en la red
byte gateway[] = { 192, 168, 1, 1 }; // ip de tu router
byte subnet[] = { 255, 255, 255, 0 }; // subnet
String json,solicitud;
float temperatura;
int tempPin = 0;
void setup() {
[Link](mac, ip, gateway, subnet);
[Link]();
}
void loop() {
temperatura = analogRead(tempPin);
temperatura = (5.0 * temperatura * 100 ) / 1024;
[Link](tempC);
[Link](" grados Celsius\n");
EthernetClient cliente = [Link]();
if ([Link]()) {
char c = [Link]();
if ( [Link]() < 100 ) { solicitud += c; }
if ( c == '\n' ) {
json = "{\"";
json += "temperatura\": \"" + (String)temperatura + "\", ";
json += "uptime\": \"" + (String)millis() + "\" ";
json += "}\n";
[Link]("HTTP/1.1 200 OK"); // enviamos cabeceras
[Link]("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
[Link]("Content-Type: text/javascript");
[Link]("Access-Control-Allow-Origin: *");
[Link]();
[Link](json); //imprimimos datos
delay(100); // esperamos un poco
[Link](); //cerramos la conexión
}
}
if ( ![Link]() ) { [Link](); }
}