Weather station using NodeMCU and OLED display


This weather station using NodeMCU uses open weather api from

Parts required for this project

  1. NodeMCU
  2. OLED I2C display
  3. Some wires and USB data cable
  4. 5v/3.3 v battery or power supply

What is NodeMCU?

Its a Development Kit based on ESP8266, integates GPIO, PWM, IIC, 1-Wire and ADC all in one board.

What is OLED display?

The OLED display doesn’t require backlight, which results in a very nice contrast in dark environments. It consumes less power when compared with other displays. The model we’re using here has only four pins and communicates with the Arduino using I2C communication protocol. There are models that come with an extra RESET pin. There are also other OLED displays that communicate using SPI communication.

Schematic / block diagram

Pin Wiring

VCC – 3.3 v


SDA – D2

SCK – D3

Setting Arduino for ESP8266/NodeMCU

Steps 1 – Launch Arduino and Update preferences with

Step 2 – Installing ESP8266 board package using Board Manager

Step 3 – Install UART driver

Step 4 – Install following libraries

  • ESP8266 Weather Station library
  • SSD 1306 OLED Library
  • JSON Streaming Parser Library

Also, sign up with to get API that we will be using in our code.


#include <ESPWiFi.h>
#include <ESPHTTPClient.h>
#include <JsonListener.h>

// time
#include <time.h> // time() ctime()
#include <sys/time.h> // struct timeval
#include <coredecls.h> // settimeofday_cb()

#include "SSD1306Wire.h"
#include "OLEDDisplayUi.h"
#include "Wire.h"
#include "OpenWeatherMapCurrent.h"
#include "OpenWeatherMapForecast.h"
#include "WeatherStationFonts.h"
#include "WeatherStationImages.h"

* Begin Settings

// WIFI - UPDATE your wifi SSID and password
const char* WIFI_SSID = "HomeNet_PS"; 
const char* WIFI_PWD = "";

#define TZ 5.5 // (utc+) TZ in hours
#define DST_MN 0 // use 60mn for summer time in some countries

// Setup
const int UPDATE_INTERVAL_SECS = 20 * 60; // Update every 20 minutes

// Display Settings - Update pin numbers below as used.
const int I2C_DISPLAY_ADDRESS = 0x3c;
#if defined(ESP8266)
const int SDA_PIN = D2;
const int SDC_PIN = D3;
const int SDA_PIN = 2; //D2;
const int SDC_PIN = 3; //D3;

// OpenWeatherMap Settings
// Sign up here to get an API key:
String OPEN_WEATHER_MAP_APP_ID = "xxxx";
Go to and search for a location. Go through the
result set and select the entry closest to the actual location you want to display 
data for. It'll be a URL like The number
at the end is what you assign to the constant below.

// Pick a language code from this list:
// Arabic - ar, Bulgarian - bg, Catalan - ca, Czech - cz, German - de, Greek - el,
// English - en, Persian (Farsi) - fa, Finnish - fi, French - fr, Galician - gl,
// Croatian - hr, Hungarian - hu, Italian - it, Japanese - ja, Korean - kr,
// Latvian - la, Lithuanian - lt, Macedonian - mk, Dutch - nl, Polish - pl,
// Portuguese - pt, Romanian - ro, Russian - ru, Swedish - se, Slovak - sk,
// Slovenian - sl, Spanish - es, Turkish - tr, Ukrainian - ua, Vietnamese - vi,
// Chinese Simplified - zh_cn, Chinese Traditional - zh_tw.
const uint8_t MAX_FORECASTS = 4;

const boolean IS_METRIC = true;




For complete code go to github at

Leave a Reply

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