Want to build a weather station project without using any sensor, and get informations about weather from all over the world ?
Using OpenWeatherMap, it be becomes a real task.
Step 1: HOW IT WORKS ?
OpenWeatherMap.org not only supply current weather data, but can also serve 5-day and 16-day forecasts, historical data, and even weather warnings.
This site provides us a free option that offer the opportunity to get the current weather and five-day forecast from any city in the world.
Step 2: THE SETUP
1. Head over to OpenWeatherMap.org.
2. You will need to sign up for their free account in order to get an API key.
To find it, log into your account, then navigate to “API Keys”, and then enter your Key name and click on generate button.
See photos above.
Step 3: THE CODE
We will be using the ESP8266 libraries and platform. The below code was tested using the NodeMCU.
First of all please ensure that you have the ESP8266 and ArduinoJSON libraries installed in your development environment.
For ESP8266 library, start Arduino and open the Preferences window.Enter :
in additional boards manager URLs filed.
Open the Boards Manager from the Tools > Board menu and find the ESP8266 platform. Select the version you need, then click the install button. select the ESP8266 board from Tools > Board menu.
For ArduinoJSON library, you can found it by searching in the Include Library > Manage Libraries.
Upload the code below to your ESP8266-Based board.
Step 4: THE RESULT
First of all you must change the code a bit,
- change ssid wih your WiFi's name.
- change password with your WiFi's password.
- put your API_KEY after : &appid=<API_KEY>
If everything is alright, upload the code to your board.
You can get the data from any city in the world.
Check the video if you stuck.
Step 5: WHERE TO FROM HERE?
This is the start of a much bigger project, so If you wanted to expand it, you could easily add OLED or LCD screens that display the current weather, and read your daily schedule in order to build a smart mirror.
Step 6: CONCLUSION
There are many weather data sources on the internet and they vary in function.
OpenWeatherMap.org has to be one of the most straightforward and elegant solutions that we have found to easy access the weather data from all over the planet.
If you have any question of course you can leave a comment.
Thanks for reading this project ^^ and have a nice day.