NodeMCU Internet weather station with SSD1306 OLED | IoT Projects

In this IoT project, I’m going to show how to make a simple internet weather station using ESP8266 NodeMCU (ESP-12E) Wi-Fi development board and SSD1306 OLED display (128×64 Pixel). The NodeMCU pulls weather data (temperature, humidity, pressure, wind speed and wind degree) from weather website and display it on SSD1306 screen.

The SSD1306 OLED used in this project is configured to work in I2C mode, some SSD1306 OLED boards may require a small hardware modifications (to select between SPI mode or I2C mode) such as soldering, placing jumpers ….

Related Projects:
ESP8266 NodeMCU interfacing with SSD1306 OLED
NodeMCU Internet clock and weather station | IoT Projects
IoT | Internet weather station with ESP8266 Wi-Fi module

ESP8266 NodeMCU internet weather station with SSD1306 display

Hardware Required:

  • ESP8266 NodeMCU development board
  • SSD1306 OLED display with 128×64 Pixel resolution
  • micro USB cable (for programming and powering the circuit)
  • Breadboard
  • Jumper wires

Internet weather station with NodeMCU and SSD1306 OLED circuit:
The following image shows project circuit schematic diagram.

ESP8266 ESP-12E nodeMCU SSD1306 OLED display circuit

And the following one shows fritzing circuit:

ESP8266 ESP-12E nodeMCU SSD1306 OLED display fritzing circuit

The SDA and SCL lines of the I2C bus come from GPIO4 (D2) and GPIO0 (D3) of the NodeMCU board (respectively), they are connected to SDA and SCL (SCK) pins of the SSD1306 display module.
Reset pin (RES) of the display module is connected to GPIO5 (D1) of the NodeMCU development board.

The SSD1306 display module is supplied with 3.3V which comes from the NodeMCU board.

Internet weather station with NodeMCU and SSD1306 OLED code:
The Arduino IDE code below uses Adafruit SSD1306 OLED driver and Adafruit GFX library for the communication between the NodeMCU and the screen module. Download links and how to install them, in the following post:
ESP8266 NodeMCU interfacing with SSD1306 OLED

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

In code, don’t forget to replace YOUR WIFI SSID and YOUR WIFI PASSWORD.

Also we can set the location and the API key using the following two lines (number 25 and 26) where in this example I’m setting the location to London, United Kingdom and the API key to my API key:

Full code:

The following image shows Arduino IDE serial monitor output:

ESP-12E NodeMCU internet weather station serial monitor

4 thoughts on “NodeMCU Internet weather station with SSD1306 OLED | IoT Projects”

  1. Arduino: 1.8.8 (Windows 10), Board: “NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Enabled, 4M (no SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 115200”

    C:\Users\walma\OneDrive\Documents\Arduino\weather_screen\weather_002\weather_002.ino: In function ‘void loop()’:

    weather_002:82:7: error: ‘DynamicJsonBuffer’ was not declared in this scope

    DynamicJsonBuffer jsonBuffer(512);

    weather_002:82:25: error: expected ‘;’ before ‘jsonBuffer’

    DynamicJsonBuffer jsonBuffer(512);

    What did I do Wrong?

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