Hello!
I have Arduino Uno + Ethernet Shield W5100 with this sketch:
#include <DHT.h>
#include <SPI.h>
#include <Ethernet.h>
#define DHTTYPE DHT22
#define DHTPIN 9
DHT dht(DHTPIN, DHTTYPE);
int dhtTemp; int dhtHum; int dhtHIC;
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x85, 0xD9 };
byte ip[] = { 192, 168, 0, 9 };
byte subnet[] = { 255, 255, 255, 0 };
byte gateway[] = { 192, 168, 0, 1 };
EthernetServer server(80);
void setup()
{
Ethernet.begin(mac,ip,gateway,subnet);
server.begin();
dht.begin();
}
void loop()
{
dhtCheck();
generateWebPage ();
}
void dhtCheck() {
dhtTemp = dht.readTemperature();
dhtHum = dht.readHumidity();
dhtHIC = dht.computeHeatIndex(dhtTemp, dhtHum, false);
}
void generateWebPage () {
EthernetClient client = server.available();
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connnection: close");
client.println();
client.println("");
client.println("");
client.println("Lair module");
client.println("<meta http-equiv="refresh" content="15">");
client.println("");
client.println("");
client.println("");
client.println("
client.println("");
client.println("");
client.println("");
client.println("");
client.println("");
client.println("");
client.println("");
client.println("");
client.println("");
client.println("
"); client.println(""); client.println("Climat in Lair"); client.println(""); client.println(" |
"); client.println("Temp: "); if (dhtHIC > 0) {client.print("+");} client.print(dhtHIC); client.println("°"); client.println(" |
"); client.println("Hum: "); client.print(dhtHum); client.println("%"); client.println(" |
client.println("");
client.println("");
delay(1);
client.stop();
}
How i can make periodical get-request to my local SmartHome server?
Request:
http://192.168.0.251:80/objects/?script=tempupdated&temp=dhtTemp&hum=dhtHum