Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "DHT.h"
- #define DHTPIN 3
- #define DHTTYPE DHT11
- DHT dht(DHTPIN, DHTTYPE);
- #include <EtherCard.h>
- int sensorPin = A0;
- int sensorValue = 0;
- static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
- static byte myip[] = { 192,168,1,6 };
- static byte gwip[] = { 192,168,1,1 };
- byte Ethernet::buffer[500];
- BufferFiller bfill;
- int t=0;
- int h=0;
- int Timer= 0;
- int Animation = 0;
- void setup () {
- pinMode(sensorPin, INPUT);
- if (ether.begin(sizeof Ethernet::buffer, mymac, 10) == 0)
- Serial.println( "scheda di rete non rilevata");
- ether.staticSetup(myip, gwip);
- dht.begin();
- }
- static void ReadDHT11()
- {
- h = dht.readHumidity();
- t = dht.readTemperature();
- }
- static word homePage() {
- bfill = ether.tcpOffset();
- bfill.emit_p(PSTR(
- "HTTP/1.0 200 OK\r\n"
- "Content-Type: text/html\r\n"
- "Pragma: no-cache\r\n"
- "\r\n"
- "<meta http-equiv='refresh' content='30'/>"
- "<title>SERRA ARDUINO</title>"
- "<h1>Temperatura: $D C <br>umidita esterna: $D %<br> umidita terreno: $D %</h1>"),
- t, h,A0);
- return bfill.position();
- }
- void loop () {
- ReadDHT11();
- word len = ether.packetReceive();
- word pos = ether.packetLoop(len);
- if (pos)
- ReadDHT11();
- ether.httpServerReply(homePage());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement