Thursday, March 28, 2024

Weather Forecasting on ESP32

By Somnath Bera. He is an electronic hobbyist and enthusiast since 2005.

In any power utility corporation ash dyke management is a huge issue. For fugitive dust control huge sprinklers that spray water all along the dry portion of the dyke are used but maintenance of these sprinklers is a problem as we really don’t have any idea when it’s going to rain or when it will be windy. So the operators in such corporations were demanding for a weather forecasting terminal to overcome this issue easily.

While a $600 laptop is enough to get data from openweather.org to have an idea when it’s going to be rainy or windy, the more better option was an ESP32  which would do the same job pretty well and that too at a fraction of cost.

One might think a better option is a simple google search, but Internet also repletes with weather servers. Finding the site, signing in and then get weather forecasting data is also hectic. Some provide data in plain http output while others prove in json or xml format. Almost all sites provide free data for few days but for more data or for archive data one needs to sign-in and buy eventually.

Of all the data servers openweathermap.org is one of the most user friendly and easy to put into ESP32. They provide data in json. The Arduino has a json library which is pretty good enough to decode data from json.

Process

Step 1: Go to openweathermap.org
Step 2: Do a sign-in and find your city code from the site.
Step 3: The site will provide an API key.
Step 4: Use this API key in the Arduino code to get json streaming data.

- Advertisement -

The simple HTTP string is supplied by the ESP32 which is received through GET protocol. The data is then processed through json, segregated and reprinted on a TFT ILI9341 screen.

Design

We have used a cheap DS3231 real-time clock to keep track of time. The DS3231 is better than most other RTC as it has an inbuilt precision temperature correction to take care of the quartz frequency correction over a very long time drift. For display, we have used TFT ILI9341 2.5”X2.0” display. The site provides free data for 5 days at a time. So much data cannot be placed on one screen, therefore, we have placed the data in two screenshots with a time division of approximately one minute each.

Schematic

Schematic is very simple and straightforward. For construction, use a small double sided Vero board.

- Advertisement -

Software

The json library & sketch is attached

Prototype

City code

City codes are like the ones given below. You can also enter the exact GPS position of your city. The full city guide is also country_code for your ready references.

Singrauli, IN
Victoria,US
Bolocovo,RU
Almaty,KZ
Darlinghurst,AU

Aftermath

While the ESP32 based display is perfectly alright to use in place of the laptop, the laptop is not removed from the site. The maximum and minimum temperature is not very precise at times but the mean temperature, wind and cloud condition is perfectly right and helps to take maintenance of these sprinkler systems.

Download Source Folder


 

4 COMMENTS

  1. Hello Somnath!
    Thank you for sharing this great weather forecaster. From my job i always need to know what kind of a weather will be in the next few day. With this little gadget my job is quite easier. I was wondering about an idea. With the next few days forecasts paired with a scrolling window and weather icons. Like Squix weather station.
    Anyway, thank you for sharing 🙂

  2. please learn to write neat code, esp. if you are providing for public consumption….horrible. refer to hackster.io contributors and basic coding examples on how to format and document your code. thank you.

SHARE YOUR THOUGHTS & COMMENTS

Electronics News

Truly Innovative Tech

MOst Popular Videos

Electronics Components

Calculators