4001

ESP32 weather forecasting can replace a costly system effortlessly

Weather forecasting on ESP32
 
Prelude:
I look after ash dyke management for 4 huge ash dykes of NTPC here. For fugitive dust control we have huge sprinklers which spray water all along the dry portion of the dyke. Taking 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 were demanding for a weather forecasting terminal for sometime. A  laptop computer with Internet facility was installed at the ash dyke.
 
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, I thought an ESP32 will do the same job pretty well and that too at a fraction of cost.
 

 
Internet is replete with weather servers. Find the site, sign in and then get weather data. Some provide data in plain http output while others prove in json or xml format. Almost all sites provide free data for few days. For more data or for archive data one needs to sign-in and buy.
 
Of all the data servers I find openweathermap.org is 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: First of all go to openweathermap.org, do a sign-in and find your city code from the site. The site will provide an API key. Use this API key in the Arduino code to get json streaming data. 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
http://api.openweathermap.org/data/2.5/forecast?q=Singrauli,IN&APPID=xxxxxxxxxxxxxxxxxx&mode=json&units=metric&cnt=37
 
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 screen shots with a time division of approximately one minute each.

Schematic: Schematic is very simple and straight forward. For construction I’ve used a small double sided vero board.
 
Software: The json library & sketch is attached
 
Prototype:
 
City code: City codes are like this. You can also enter the exact GPS position of your city. The full city guide is also attached here for your ready references.
Singrauli, IN
Victoria,US
Bolocovo,RU
Almaty,KZ
Darlinghurst,AU
 
Additional attachment: city code guide (3.1 MB text file)
 
Aftermath: While the ESP32 based display is perfectly alright to use in place of the laptop, the lap top is not removed from the site. The maximum and minimum temperature is not very precise at times but the mean temp, wind and cloud condition is perfectly right and helps to take maintenance of these sprinkler systems.
 
S. Bera
Vindhyanagar