arduino_sensor_V2_ Bloc de notas
arduino_sensor_V2_ Bloc de notas
h>
#include <DHT_U.h>
#include <WiFi.h>
#include <HTTPClient.h>
void setup()
{
Serial.begin(9600);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.println("Conectando");
while(WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Conectado a la red WiFi con direccion IP: ");
Serial.println(WiFi.localIP());
dht.begin();
}
void loop()
{
delay (2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t))
{
Serial.println("No se pudo leer el sensor DHT!");
return;
}
{
// HTTP header has been send and Server response header has been handled
Serial.printf("[HTTP] GET... code: %d\n", httpCode);
}
} else {
Serial.printf("[HTTP] GET... failed, error: %s\n",
http.errorToString(httpCode).c_str());
}
http.end();
delay(180000); // WAIT Thre MINUTES BEFORE SENDING AGAIN
}