Introduction: Autonomous Weather Station With ESP8266

About: Fundador de The Inventor's House Hackerspace, Movimiento Maker y Hardware Libre, DIY, Workaholic

Hola amigos

Hoy les vamos a mostrar como realizar una pequeña estación meteorológica con nuestro ESP8266 NodeMCU, nuestra estación va a reportar temperatura, humedad y punto de rocío a la comunidad global de wunderground con esto contribuiremos a generar un mejor pronostico de la ciudad donde vivimos, algo que hace especial a nuestra estación meteorológica es que es completamente autónoma trabaja únicamente mediante energía solar que proporciona una celda solar y por la noche gracias al BackPack para el NodeMCU y una batería Lipo puede trabajar durante la noche sin requerir ser conectado a una fuente de alimentación, si la batería llega a un estado critico de voltaje el ESP8266 enviara una notificación a IFTTT que nos notificara a nuestro correo, smartphone o twitter.

Una vez explicado las funcionalidades, comencemos

Today we're going to make a tiny weather station with our ESP8266 NodeMCU which will report temperature, humidity and dew point to the global community, wunderground with this station we'll get a better weather forecast of the city where we live, something that makes this tiny weather station, especial is that it works only by SOLAR ENERGY which is provided by a solar panel and by the night with a Lipo battery due to the backpack and it works all the night long without any electrical connection, if the battery level goes on a critical state of voltage the ESP8266 will notifie you by IFTTT by Mail Smartphone or twitter

Once explained its features, lets get started

Step 1: Material

El material necesario para realizar este proyecto es:

  • ESP8266 NodeMCU o cualquier versión del ESP8266
  • Celda Solar Brown Dog Gadgets
  • BackPack Lipo para NodeMCU disponible en Tindie
  • Sensor DHT11
  • Bateria Lipo compatible

Ustedes pueden agregar algunos otros sensores a su estación si gustan como puede ser de velocidad del viento o rayos UV .

The necesary material to get done this proyect is:

  • ESP8266 NodeMCU o or any version of the ESP8266
  • Solar cell Brown Dog Gadgets
  • BackPack Lipo para NodeMCU available on Tindie
  • Sensor DHT11
  • LiPo Battery compatible

You can add some other sensors to your weather station if you like, sensors like wind speed or UV

Step 2: IFTTT

Para la parte de alertas por baja batería en nuestra estación usaremos la API del servicio IFTTT que nos permite por medio del canal Maker hacer una notificación a nuestro celular con diversos servicios como gmail. twitter, facebook y mas.

Tendremos que tener instalada la aplicación IFTTT en nuestro smartphone una vez abierto iremos a crear una receta como se muestra en las imágenes, seleccionando primero el trigger el cual en este caso es el Web request de el servicio MAKER ahí necesitaremos ingresar el nombre de nuestro evento (lo necesitaremos mas delante) después seleccionaremos la acción a realizar por el celular en este caso sera la notificacion por parte de la aplicacion, mas tu puedes elegir cualquiera.

By the low battery alert in our station we're going to use the IFTTT API which allows by the maker channel to make a notification on our smartphone with many services like gmail Facebook and more.

We'll need to have installed the IFTTT app in our smartphone, once open we're going to create a new recipe like is shown in the screenshots, slsecting first the trigger which in this case is Web Request of the Maker service, there we need to add the event name (Save this name) after this we select the action to do, in this case we slect notification by the application, but you can select any else.

Step 3: IFTT Key

Para realizar la conexión con el ESP8266 necesitaremos una KEY que nos provee la misma aplicación esa KEY la usaremos en el código para hacer la Web Request asi que hay que anotarla.

Para acceder a la key accederemos como si quisiéramos crear una nueva receta pero con al diferencia que ahora nos seleccionaremos el servicio Maker ya dentro iremos a configuraciones y ahí encontraremos nuestra KEY.

To do the conection with the ESP8266 we'll need a KEY supplied by the same APP that KEY is used in the code in order to make the Web Request so you may want to write it.

To access the key accede as if we want to create a new recipe but with the difference that we now select the Maker service and then go to settings and there we will find our KEY.

Step 4: Wunderground API

Para crear la estación climática deberemos entrar a wunderground y crear una cuenta, una vez ya loggeado la crearemos con 5 sencillos pasos.

  1. Iremos a "My weather stations" dando click donde indica la primera imagen.
  2. Ya ahí daremos click donde indica la segunda imagen para crear una estación climática.
  3. Con la ayuda de Google maps ubicaremos nuestra estación climática e ingresaremos a cuantos pies de altura esta.
  4. Llenaremos los campos siguientes lo único necesario es el nombre de la colonia y de preferencia hay que llenar todos con los que cumpla nuestra estación, En hardware empleado seleccionaras "Other"
  5. Guardaremos nuestra ID para usarla en el código mas delante y poder mandar información.

Listo terminamos de crear y configurar nuestra estación climática es hora de usarla con nuestro ESP8266.

To create our weather station we will enter to wunderground and sign in, once logged in we create it in 5 steps

  1. Go to "My weather stations" clicking where the first image says
  2. Click where the second imagen says to create a new weather station
  3. With Google maps help we select the ubication of our station and dont forget to add the distance between the floor and the station
  4. Complete al the next fields, the only required field is your neighborhood but if you can add more information it would be great
  5. Save your ID to use it in the code more ahead

Ready we have finished now is time to use our station with the ESP8266

Step 5: Codigo

Una vez preparado todo es hora de programar nuestro ESP8266por medio del Arduino IDE y el plugin para ESP8266, en el programa habrá que hacer los cambios necesarios dependiendo de tu SSID tu contraseña sus KEY's e ID generadas anteriormente.

Once preparated all its time to program our ESP8266 by the Arduino IDE and the plugin of the ESP8266, in the program you will need to change some information like your SSID Password your Key's and ID previously generated.

Github:

https://github.com/wero1414/ESPWeatherStation/blob...

#include #include "DHT.h" #define DHTPIN 2 //Pin to attach the DHT#define DHTTYPE DHT11 //type of DTH const char* ssid = "Your SSID"; const char* password = "Your password";const int sleepTimeS = 600; //18000 for Half hour, 300 for 5 minutes etc.

///////////////Weather//////////////////////// char server [] = "weatherstation.wunderground.com"; char WEBPAGE [] = "GET /weatherstation/updateweatherstation.php?";char ID [] = "YourWeatherID";char PASSWORD [] = "YourPasswordOfWunderground";

/////////////IFTTT///////////////////////
const char* host = "maker.ifttt.com";//dont changeconst String IFTTT_Event = "YourEventName"; const int puertoHost = 80;const String Maker_Key = "YourMakerKey";String conexionIF = "POST /trigger/"+IFTTT_Event+"/with/key/"+Maker_Key +" HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n\r\n";
//////////////////////////////////////////
DHT dht(DHTPIN, DHTTYPE);
void setup(){ Serial.begin(115200); dht.begin(); delay(1000); Serial.println(); Serial.print("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); }} void loop(){ //Check battery int level = analogRead(A0); level = map(level, 0, 1024, 0, 100); if(level<50) { mandarNot(); //Send IFTT Serial.println("Low batter"); delay(500); } //Get sensor data float tempc = dht.readTemperature(); float tempf = (tempc * 9.0)/ 5.0 + 32.0; float humidity = dht.readHumidity(); float dewptf = (dewPoint(tempf, dht.readHumidity())); //check sensor data Serial.println("+++++++++++++++++++++++++"); Serial.print("tempF= "); Serial.print(tempf); Serial.println(" *F"); Serial.print("tempC= "); Serial.print(tempc); Serial.println(" *C"); Serial.print("dew point= "); Serial.println(dewptf); Serial.print("humidity= "); Serial.println(humidity); //Send data to Weather Underground Serial.print("connecting to "); Serial.println(server); WiFiClient client; if (!client.connect(server, 80)) { Serial.println("Conection Fail"); return; } client.print(WEBPAGE); client.print("ID="); client.print(ID); client.print("&PASSWORD="); client.print(PASSWORD); client.print("&dateutc="); client.print("now"); client.print("&tempf="); client.print(tempf); client.print("&dewptf="); client.print(dewptf); client.print("&humidity="); client.print(humidity); client.print("&softwaretype=ESP%208266O%20version1&action=updateraw&realtime=1&rtfreq=2.5"); client.println(); delay(2500); sleepMode(); }
double dewPoint(double tempf, double humidity) //Calculate dew Point{ double A0= 373.15/(273.15 + tempf); double SUM = -7.90298 * (A0-1); SUM += 5.02808 * log10(A0); SUM += -1.3816e-7 * (pow(10, (11.344*(1-1/A0)))-1) ; SUM += 8.1328e-3 * (pow(10,(-3.49149*(A0-1)))-1) ; SUM += log10(1013.246); double VP = pow(10, SUM-3) * humidity; double T = log(VP/0.61078); return (241.88 * T) / (17.558-T);} void mandarNot(){ WiFiClient client; if (!client.connect(host, puertoHost)) //Check connection { Serial.println("Failed connection"); return; } client.print(conexionIF);//Send information delay(10); while(client.available()) { String line = client.readStringUntil('\r'); Serial.print(line); }} void sleepMode(){ Serial.print(F("Sleeping...")); ESP.deepSleep(sleepTimeS * 1000000);}

Step 6: Circuito

El circuito es relativamente sencillo solo recuerde que nosotros en la batería estamos usando el Backpack NodeMCU Lipo que nos permite cargar la batería por medio del USB e igual alimentar nuestra tarjeta.

La conexión a nuestro sensor de temperatura y humedad DHT11 es muy sencilla como cualquier otro circuito de Arduino.

Hemos puenteado el GPIO16 (D4) con el reset para poder usar el modo de sueño y ahorrar batería mientras nuestra estación no esta enviando datos, si usted no coloca este puente el nodeMCU nunca regresara del modo sueño "sueño infinito".

Hemos conectado a nuestra entrada analógica por medio de una arreglo de resistencias nuestra batería para poder monitorear su nivel de voltaje y al llegar a un nivel muy bajo se nos enviara una notificación por IFTTT

MUY IMPORTANTE:el NodeMCU es el único que tiene estas resistencias internas incluidas, si usted esta usando otra versión de ESP8266 no conecte directamente


This circuit is easy but you need to remember that we are using the Backpack NodeMCU Lipo which allows the charge of a Lipo battery by the USB connector and by the time supply our ESP

The conection of the temperature and humidity sensor DHT11 is very easy like any other arduino circuit.

We have conect the GPIO16 (D4) to the Reset PIN in order to use the Sleep mode and save energy of our battery while the station isnt sending information if you forget this conecton the ESP8266 wont comeback from sleep mode

We have conect our analog input by a resistance array to our battery for monitoring the voltage level and by the time it goes to low it will connect with the IFTTT and send the notification to our smartphone.

Very important: The NodeMCU is the only model that has that resistance array, if youre using any other version of the ESP8266 DO NOT connect the ADC direct to the battery.

Step 7: Trabajando

Una vez cargado el programa en nuestro ESP8266, conectamos todo a nuestro NodeMCU, batería, celda solar y DHT11 para que empiece enviar la información a la pagina de wunderground, durante el día nuestra estación podrá trabajar y cargar la batería gracias a la celda solar, durante la noche trabajara gracias a la bateria, hemos implementado un modo de sueño para que solo cada 10 minutos envié información a la pagina y el resto del tiempo este ahorrando energia.

Gracias a mi amigo Wero por el apoyo llevado acabó para realizar este instructable
Versión en inglés gracias a Wero.

Esperamos les haya gustado este instructable, hasta la próxima inventores!!

Once uploaded to our ESP8266 conect all Battery Solar Cell and DHT11 and it will start sending information to the page of wunderground, by the day it will work with the solar cell and by the night it will work with the battery, we have put the sleepmode each 10 minutes so, it sends information each 10 minutes that time can be change. And it saves energy while it is sleeping.

Thanks to my friend wero by his support to get done this instructable
English version by wero Hope you liked this instructable see you next time inventor's!!

Rainy Day Challenge

Participated in the
Rainy Day Challenge