From 9144780751c419cd5cf50ddeed51f98d5f983592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Mon, 7 Dec 2015 00:40:33 +0100 Subject: [PATCH] --- iot-dht11-esp8266.ino | 177 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 iot-dht11-esp8266.ino diff --git a/iot-dht11-esp8266.ino b/iot-dht11-esp8266.ino new file mode 100644 index 0000000..92e841e --- /dev/null +++ b/iot-dht11-esp8266.ino @@ -0,0 +1,177 @@ +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#define DHTTYPE DHT11 +#define DHTPIN 2 + +DHT dht(DHTPIN, DHTTYPE, 11); // 11 works fine for ESP8266 + +const char* ssid = "***REMOVED***"; +const char* password = "***REMOVED***"; +MDNSResponder mdns; + +ESP8266WebServer server(80); +LiquidCrystal_I2C lcd(0x27,20,4); + +const int led = 13; +String tempGlobal = ""; +float temperature; +float humidity; +int count = 0; + +Ticker flipper; + +void apagar() { + for (uint8_t i=0; i100){ + HTTPClient http; + http.begin("api.thingspeak.com", 80, "/update"); + http.addHeader("X-THINGSPEAKAPIKEY", "P1U0MJLKTAOL3TCI"); + int code = http.POST("field1="+String(temperature,2)+"&field2="+String(humidity,2)); + Serial.print("HTTP code: "); + Serial.println(code); + count = 0; + } + +} + +void handleRoot() { + + +// actualizar(); + + + String message = "

La temperatura

" + String(temperature,0) + "

La humedad

" + String(humidity,2) + "

Nueva temperatura:
"; + server.send(200, "text/html", message); +} + +void handleNotFound(){ + digitalWrite(led, 1); +// String message = "File Not Found\n\n"; + String message = "URI: "; + message += server.uri(); +// message += "\nMethod: "; +// message += (server.method() == HTTP_GET)?"GET":"POST"; +// message += "\nArguments: "; +// message += server.args(); +// message += "\n"; +// for (uint8_t i=0; i