ESP8266 IOT WEATHER STATION (Windguru, Windy.com, WUnderground...)

by alvareztelecom7 in Circuits > Arduino

70 Views, 1 Favorites, 0 Comments

ESP8266 IOT WEATHER STATION (Windguru, Windy.com, WUnderground...)

weather3.jpg
weather_stat.jpg
WEATHER2.jpg
estacion_meteorologica_casera.jpg

I make a micro weather station with few and extremely cheap materials (less than 10 euros).

As a base I use a Nodemcu ESP8266 board, which is programmed like an Arduino and a small board with two high quality sensors (AHT+BMP280). The intention is to collect some meteorological parameters such as temperature, humidity and atmospheric pressure, and to be able to view them through any device connected to the Internet such as a mobile phone or a PC.

I use the Ardubridge.com platform as a gateway to send the data to Windguru, Windy.com and WeatherUnderground, as well as generating my own custom site on the same platform.

The source code to use is really small, I only have to make the connection with a website, then the platform sends the data to the other websites on behalf of my station. My custom page in Ardubridge looks like this: see micro weather station.

Supplies

nodemcu_esp8266_v3.jpg
sensor_aht20_bmp280.jpg
  1. NodeMCU esp8266 V3 board (aliexpress, amazon)
  2. AHT20+BMP280 sensor (aliexpress, amazon)
  3. Micro USB cable charge and data (aliexpress, amazon)
  4. Plastic box (aliexpress, amazon)
  5. Neodymium magnets (aliexpress, amazon)

The minimum materials are the ESP8266 NodeMCU board and the AHT20+BMP280 sensor board. The rest of the materials, such as the junction box or the neodymium magnets, are optional. As a USB programming and power cable, you can reuse the cable from an old mobile phone charger that supports data.

Electric Diagram

esquema_electrico_estacion_meteo.jpg

Explanation of the electrical diagram: The NodeMcu board can be powered by the VIN (+) and G (-) pins with 5v DC or with a simple micro USB cable and a mobile phone charger, which applies the same 5v voltage. From the 3V (+) and G (-) pins, we get a 3.3v power supply for the AHT20+BMP280 board. I usually use red and black cables for positive and negative DC power. Through the D1 (SCL) and D2 (SDA) pins we connect to the pins of the same name on the sensor board. For the data communication cables I usually use purple cable, in this case the communication is via I2C protocol.

Assembly

estacion_meteorologica_diy.jpg
estacion_meteorologica_esp8266.jpg
Micro Estación Meteorológica con NodeMCU ESP8266 por ¡Menos de 10€! (1/2)

We machine a hole in the lower area of ​​the register box to later pass the USB cable through. We can do this operation with a drill and a bit, or with a small file.

Don't worry if the hole is too big and you intend to put your station outside, this hole will stay in the lower area and water will not get in. We insert the main board inside the small register box, in our selected box, from the manufacturer Famatel, I must say that it fits like a glove. See the following photograph.

Then, to avoid problems with short circuits and unwanted connections, we insert a small transparent acetate sheet between the main board and the sensor board. We connect the USB cable at one end to the NodeMCU board, at the other end to a typical mobile phone charger.


Connect to Ardubridge

alta_estacion2.jpg
alta_estacion.jpg
ardubridge_id_estacion.jpg

* Before uploading the code to our board, we must register in Ardubridge, register a new station in the panel and obtain the station id and station password. We will start by registering in the FREE SIGNUP area with our name, email and password, remember to verify the email by clicking on the email received.


* Once the email has been verified, we log in to the page. In the panel, we register the new station with Add Weather Station as in the following image. In the station registration form we will be asked for the API or station password, we must invent one so that only we can send data on behalf of our station.


* Once the station is registered, we will see that a new row is generated on the main page of the panel with the main information of our new station. One of the main data is the status, to verify if everything is synchronizing well, initially the status will appear as PENDING DATA in red, when we start sending data, it will change to RECEIVING DATA in green. On the left side we will see the station id that has been assigned to us, which together with the station pass, we will use in the next step to load the programming and start sending meteorological data.

Programming

It is time to connect the USB cable to our mini weather station and to the PC. Open the ARDUINO IDE programming environment and upload the code. But initially we must install the libraries for everything to work correctly, the first one you can download from the link attached, the rest, from the library of libraries of the same ARDUINO IDE:

  1. Ardubridge.h (necessary to contact Ardubridge with the minimum possible code)
  2. ESP8266WiFi.h (install from library, necessary to connect via wifi)
  3. ESP8266HTTPClient.h (install from library library, necessary to send data over the Internet)
  4. Wire.h (necessary for i2c)
  5. SPI.h (necessary for i2c)
  6. Adafruit_Sensor.h (library to read the sensors we have in a simpler way)
  7. Adafruit_BMP280.h (necessary for BMP280 sensor)
  8. Adafruit_AHTx0.h (necessary for AHT20 sensor)


If you don't know how to install libraries, here is a link where they explain it in a very simple way. Later we will copy the following source code (also you can copy the code from Henryfab):

#include <Ardubridge.h> // lib to send data to Ardubridge.com
#include <Wire.h> // lib i2c devices
#include <SPI.h> // lib also for 12c devices
#include <Adafruit_Sensor.h> // unified library for sensors
#include <Adafruit_BMP280.h> // lib temp and humidity
#include <Adafruit_AHTX0.h> // lib temp and preassure
// Ardubridge library instance
Ardubridge ardubridge;
// Constants for BMP280 sensor
#define BMP_SCK 13
#define BMP_MISO 12
#define BMP_MOSI 11
#define BMP_CS 10
// Instances definition for I2C sensors
Adafruit_BMP280 bme; // temp and preassure
Adafruit_AHTX0 aht; // temp and humidity
// Timers for serial print info
unsigned long currentTime = millis();
unsigned long timer1 = 10000; // time for print by serial monitor (10 seg)
unsigned long prev1 = 0;
// Meteo variables definition
float lectura_temperatura;
float lectura_presion;
float lectura_humedad;
void setup() {
Serial.begin(9600);

// ARDUBRIDGE LIBRARY - Configure the WiFi connection and the Ardubridge station
ardubridge.setup("nombre_wifi", "password_wifi", "station_id", "station_pass", 3);
// Checking I2C sensor AHT10
if (!aht.begin()) {
Serial.println("Could not find a valid AHT10 sensor, check wiring!");
while (1);
}
// Checking I2C sensor BMP280
if (!bme.begin()) {
Serial.println("Could not find a valid BMP280 sensor, check wiring!");
while (1);
}
}
void loop() {
// Reading sensors
sensors_event_t humidity, temp;
aht.getEvent(&humidity, &temp);
lectura_temperatura = temp.temperature; // read temp from aht10
lectura_humedad = humidity.relative_humidity; // read humidity from aht10
lectura_presion = bme.readPressure() / 100; // read preassure from bmp280
// Show reading values by serial monitor each 10 sec (optional)
if( millis() - prev1 > timer1 ){
prev1 = millis();
Serial.println(" ");
Serial.print("Temperature: ");
Serial.println(lectura_temperatura);
Serial.print("Humidity: ");
Serial.println(lectura_humedad);
Serial.print("Pressure = ");
Serial.println(lectura_presion);
Serial.println(" ");
}
// ARDUBRIDGE LIBRARY - Update the meteo variable values
ardubridge.setTemperature(lectura_temperatura);
ardubridge.setHumidity(lectura_humedad);
ardubridge.setPressure(lectura_presion);
//ardubridge.setWindDirection(5.0);
//ardubridge.setWindSpeed(5.0);
//ardubridge.setWindSpeedMin(5.0);
//ardubridge.setWindSpeedMax(5.0);
//ardubridge.setPrecipitation(5.0);
//ardubridge.setUV(5.0);
//ardubridge.setDewPoint(5.0);
// ARDUBRIDGE LIBRARY - Call loop method to send the data.
ardubridge.loop();
}


On line 35 there are four parameters that we need to replace, remember to keep the current quotes, we only modify the text inside:

  1. Parameter 1: name of your wifi.
  2. Parameter 2: password of your wifi.
  3. Parameter 3: your STATION ID (we got it in the previous step).
  4. Parameter 4: your STATION PASS or API pass (we generated it in the previous step).
  5. Parameter 5: number of minutes every how we want to send weather parameters, by default 3, it is recommended not to change.

As you can see with only 85 lines of code, we have our station ready to send our weather parameters to a lot of websites. You can also modify this code and add more sensors.

On lines 75 to 81 you can see how we have commented the lines because we do not have sensors for these parameters.

If you have such sensors, you can replace the fixed values ​​in the parentheses with the name of the reading variables, so you can complete your station in a modular way.

With these steps completed, you can now upload the code to your NodeMCU board.

As long as you have it connected to your PC with the IDE open, you can see the reading status and the moment of connecting to Ardubridge on the serial monitor every 10 seconds.

Afterwards, you just have to leave our mini station connected via USB to a mobile phone charger.

Connect With Windguru, Windy and WUnderground

weather_station_to_windguru.jpg

With the steps above completed, our station status will soon be in RECEIVING DATA mode with a green background. On the right we will see SEE STATION to see our custom page with the data we are already sending.

You can edit your station to add latitude and longitude to bring up a location map, it is easy to get this data by simply opening google maps.

It is time to connect to Windguru, Windy and WeatherUnderground. We will click on ADD NEW LINK, it will take us to a form with two drop-down menus, one to select our station and another to select the web page we want to link it to.

After choosing one of these pages, for example Windguru, we will see the data we need to make the link and links to the pages where we must register.

Specifically Windguru asks us for this data: Windguru ID, UID and API password.

With this data added, we will be sending our weather data to Windguru and other sites in a matter of minutes.


Please, if you have any questions about programming, integration or related to Ardubridge, write to me here in Instructables comments.

Thank you very much!