Home > Projects > Sensor – Transducer – Detector Projects > Weather Forecasting on ESP32

Weather Forecasting on ESP32

Summary of Weather Forecasting on ESP32


This article details a low-cost weather forecasting terminal built with an ESP32 to optimize power utility ash dyke sprinkler maintenance. By integrating real-time data from OpenWeatherMap, the system helps operators decide when to activate sprinklers based on predicted rain and wind, replacing expensive laptops or manual searches. The project features a compact design using a DS3231 RTC for accurate timekeeping and displays five-day forecasts on a TFT screen in alternating views.

Parts used in the Weather Forecasting Terminal:

  • ESP32 microcontroller
  • Laptop (for comparison)
  • OpenWeatherMap API service
  • TFT ILI9341 2.5 inch by 2.0 inch display
  • DS3231 Real-Time Clock module
  • Arduino JSON library
  • Double sided Vero board

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 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.

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 link.

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.

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

Read More Detail :Weather Forecasting on ESP32

Quick Solutions to Questions related to Weather Forecasting Terminal:

  • Why was the ESP32 chosen over a laptop for this project?
    The ESP32 offers a better option at a fraction of the cost while performing the same job of retrieving weather data.
  • How does the system handle the limitation of free data availability?
    The site provides free data for five days at a time, which is displayed across two screenshots with a one-minute time division.
  • What specific weather conditions help maintain sprinkler systems?
    The mean temperature, wind, and cloud condition data are perfectly right and help take maintenance of these sprinkler systems.
  • Why is the DS3231 preferred over other RTC modules?
    The DS3231 has an inbuilt precision temperature correction to take care of quartz frequency correction over a very long time drift.
  • What protocol is used to retrieve data from the server?
    A simple HTTP string is supplied by the ESP32 which is received through the GET protocol.
  • How can users find their city code for the system?
    Users can sign in to openweathermap.org to find their city code or enter the exact GPS position of their city.
  • What format does OpenWeatherMap provide data in?
    OpenWeatherMap provides data in json format, which the Arduino json library can decode effectively.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter
Scroll to Top