ESP8266 IOT WEATHER STATION (Windguru, Windy.com, WUnderground...)
by alvareztelecom7 in Circuits > Arduino
243 Views, 2 Favorites, 0 Comments
ESP8266 IOT WEATHER STATION (Windguru, Windy.com, WUnderground...)
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 board (aliexpress, amazon)
- AHT20+BMP280 sensor (aliexpress, amazon)
- Micro USB cable charge and data (aliexpress, amazon)
- Plastic box (aliexpress, amazon)
- 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
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
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
* 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:
- Ardubridge.h (necessary to contact Ardubridge with the minimum possible code)
- ESP8266WiFi.h (install from library, necessary to connect via wifi)
- ESP8266HTTPClient.h (install from library library, necessary to send data over the Internet)
- Wire.h (necessary for i2c)
- SPI.h (necessary for i2c)
- Adafruit_Sensor.h (library to read the sensors we have in a simpler way)
- Adafruit_BMP280.h (necessary for BMP280 sensor)
- 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):
On line 35 there are four parameters that we need to replace, remember to keep the current quotes, we only modify the text inside:
- Parameter 1: name of your wifi.
- Parameter 2: password of your wifi.
- Parameter 3: your STATION ID (we got it in the previous step).
- Parameter 4: your STATION PASS or API pass (we generated it in the previous step).
- 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
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!