IoT | Internet weather station with ESP8266 Wi-Fi module

In this post I’m going to show how to build a simple internet weather station with ESP8266 (ESP-01)  Wi-Fi module.
The ESP8266 can access the internet (web pages) and gets weather data from websites that provide free weather information for many cities over the world. In this project I’m going to show how to get weather data from the internet and print it on Arduino IDE serial monitor.

Before I start, if you want to see how to use the ESP-01 module for the first time, how to use it with Arduino IDE and how to program (upload sketches) it with Arduino or FT232RL module, visit the following topic:
ESP8266 WiFi module programming with Arduino UNO board

Hardware Required:

  • ESP8266 ESP-01 WiFi module (or NodeMCU module)
  • FT232RL USB-to-Serial converter or equivalent
  • 3.3V source  —  or  —  5V source and AMS1117-3V3 voltage regulator
  • Breadboard
  • Jumper wires

Internet weather station with ESP8266 module circuit:
IoT project circuit diagram is shown below.

IoT projects ESP-01 ESP8266 internet weather station circuit

(All grounded terminals are connected together)

The recommended operating voltage of the ESP8266 (ESP-01) module is 3.3V and I’ve a 5V power source which means I’ve to step-down the 5V into 3.3V, for that I used the AMS1117-3.3V (LM1117-3.3V) voltage regulator. There is no need for the voltage regulator if there is available 3.3V source with 1A or higher.

RX pin of the ESP-01 module is connected to TX pin of the FT232RL USB-to-Serial module.
TX pin of the ESP-01 module is connected to RX pin of the FT232RL USB-to-Serial module.

Internet weather station with ESP8266 module code:
To get weather data, I used website, so first we’ve to sign up for a free account in order to get an API key which is important in this project. With the website we can:

  • Access current weather data for any location including over 200,000 cities
  • Current weather is frequently updated based on global models and data from more than 40,000 weather stations
  • Data is available in JSON, XML, or HTML format
  • Available for Free and all other paid accounts

Once you sign in to your account (of course after the free registration), you’ll be directed to member area, go to API keys and you’ll find your API key as shown in the following image: api key

The API code is well shown, we’ll use it later.
With that key we can access weather data provided by the website, all what we do is entering the following URL into web browser (google Chrome, Mozilla Firefox …):

Replace CITY by with the city you want weather data for, COUNTRY_CODE with the country code for that city (for example uk for the United Kingdom, us for the USA …) and YOUR_API_KEY with your API key which is shown above.

For example the weather in London, United Kingdom URL is (with my API key):,uk&APPID=1041444a18cfb8448343254a45721b1d

Accessing this URL with a web browser gives:

weather station json

As mentioned above the website provides weather data in JSON, XML, or HTML format. In this project we’ll use the JSON format which can be parsed using an Arduino library called ArduinoJSON.

Installing ArduinoJson library:
It’s easy to install the ArduinoJson library, we can do it by going to:
Arduino IDE –> Sketch –> Include Library –> Manage Libraries…
a new window will open, in the search box write: arduinojson
choose library version (I’m using version 5.13.2) and click on install.

We can install the library manually by downloading it from the following URL:
ArduinoJSON library
After the download, extract the zipped file and a folder with name ArduinoJSON-5.13.2 should appear. Move the folder to Arduino libraries folder, the folder should be renamed to ArduinoJSON (remove -5.13.2).

With a built-in library named: ESP8266HTTPClient we can read http pages, accessing a page is simple with this library, just by putting its URL as shown below where I placed the URL of London city weather:

After that we’ve to read and save the whole JSON page as a string:

And finally the ArduinoJSON library does its job and decodes the JSON string:

the website provides temperature in °K (degree Kelvin) and to convert the °K into °C (degree Celsius) we’ve to substruct 273.15 from it. For that I used the following line:

Also, it gives the pressure in hPa (Hectopascal) with 1 hPa = 100 Pascal = 1/1000 bar:

Humidity is in %, wind speed in m/s (meters per second) and wind degree in degrees (°).

The following website provides a good help with JSON format:
ArduinoJson Assistant

Full Arduino code, don’t forget to replace YOUR SSID and YOUR WIFI PASSWORD:

The following image shows my serial monitor output:

arduino ide esp8266 internet weather station output

1 thought on “IoT | Internet weather station with ESP8266 Wi-Fi module”

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top