Interfacing NodeMCU with DHT22 sensor and SSD1306 OLED

Last time I’ve connected ESP8266 NodeMCU development board (ESP-12E) with DHT11 sensor and SSD1306 OLED display. This post shows how to interface the NodeMCU with DHT22 (AM2302) digital humidity/temperature sensor and SSD1306 display (128×64 Pixel).
The NodeMCU reads temperature and relative humidity from the DHT22 sensor and prints it on Arduino IDE serial monitor and the SSD1306 OLED display.

The SSD1306 OLED used in this post projects 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:
To see how to connect the SSD1306 OLED with NodeMCU board see the following post:
ESP8266 NodeMCU interfacing with SSD1306 OLED
ESP8266 NodeMCU interfacing with DHT11 sensor and SSD1306
Arduino with DHT22 sensor and LCD

NodeMCU with SSD1306 OLED and DHT22 AM2302

Hardware Required:

  • NodeMCU development board
  • SSD1306 OLED screen (128×64 Pixel)
  • DHT22 (AM2302) temperature and humidity sensor
  • 4.7k ohm resistor
  • Micro USB cable (for programming and powering the whole circuit)
  • Breadboard
  • Jumper wires

Interfacing NodeMCU with DHT22 sensor and SSD1306 OLED circuit:
Project circuit schematic diagram is shown below.

ESP8266 NodeMCU DHT22 AM2302 SSD1306 OLED circuit

and the second image shows fritzing breadboard circuit:

ESP8266 NodeMCU SSD1306 OLED DHT11 AM2302 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 DHT22 (AM2302) sensor has 4 pins (from left to right): VCC (+5V), data pin, NC (not connected pin) and GND. The data pin is connected to pin D5 (GPIO14). A pull-up resistor of 4.7k ohm is required for the data pin.

The SSD1306 display module and the DHT22 (AM2302) sensor are supplied with 3.3V which comes from the NodeMCU board.

Interfacing NodeMCU with DHT22 sensor and SSD1306 OLED code:
In this project i used two libraries from Adafruit: the first one is for the SSD1306 OLED display (with graphics library) and the second is for the DHT11 sensor.
Adafruit library for DHT series (after extracting put the folder named DHT in the library folder of Arduino):

Arduino IDE serial monitor output for temperature and relative humidity is shown below:

NodeMCU with DHT22 humidity and temperature sensor output

Discover more from Simple Circuit

Subscribe to get the latest posts sent to your email.

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