Interfacing NodeMCU with DHT22 Sensor and Nokia LCD

This NodeMCU project shows how to interface this board with DHT22 (AM2302) digital humidity & temperature sensor and Nokia 5110 LCD (84×48 pixel resolution).
The NodeMCU microcontroller (ESP8266EX) reads temperature & humidity values from the DHT22 (AM2302) sensor and prints them (respectively in °C and RH%) on the Nokia 5110 LCD display.

To see how to interface NodeMCU board with Nokia 5110 LCD, visit this post:
Interfacing ESP8266 NodeMCU with Nokia 5110 LCD

The DHT22 sensor has the following characteristics:

  • Humidity Range: 0 ~ 100% RH
  • Humidity Accuracy: ±2% RH (max ±5% RH)
  • Temperature Range: -40 ~ 80 °C
  • Temperature Accuracy: ±0.5 °C
  • Operating Voltage: 3.3V ~ 5.5V
  • Resolution = 0.1

Hardware Required:

  • NodeMCU development board
  • Nokia 5110 LCD module
  • DHT22 (AM2302) humidity and temperature sensor   —->  datasheet
  • 4.7k ohm resistor
  • Micro USB cable (for programming and powering the whole circuit)
  • Breadboard
  • Jumper wires

NodeMCU with DHT22 sensor and Nokia 5110 LCD

NodeMCU with DHT22 sensor and Nokia 5110 LCD circuit:
Project circuit diagram is shown below.

The DHT22 sensor has 4 pins (from left to right):
Pin 1 is power supply pin, connected NodeMCU 3V3 pin,
Pin 2: data output pin, connected to NodeMCU digital pin 5 (D5),
Pin 3: not connected pin,
Pin 4: GND (ground), connected to NodeMCU GND pin.

ESP8266 NodeMCU Nokia 5110 DHT22 AM2302 circuit

The Nokia 5110 LCD which is shown in the circuit diagram has 8 pins (from left to right): RST (reset), CE (chip enable), DC (or D/C: data/command), Din (data in), Clk (clock), VCC (3.3V), BL (back light) and Gnd (ground).

The Nokia 5110 LCD is connected to the NodeMCU board as follows:
RST (reset) pin is connected to pin D0 (ESP8266EX GPIO16),
CE (chip enable) pin is connected to pin D1 (ESP8266EX GPIO5),
DC (data/command) pin is connected to pin D2 (ESP8266EX GPIO4),
DIN (data in)  pin is connected to pin D3 (ESP8266EX GPIO0),
CLK (clock) pin is connected to pin D4 (ESP8266EX GPIO2),
VCC and BL are connected to pin 3V3,
GND is connected to pin GND.

NodeMCU with DHT22 sensor and Nokia 5110 LCD code:
The following Arduino code requires 3 libraries from Adafruit Industries:
The first library is a driver for the Nokia 5110 LCD (PCD8544 controller), download link is below:
Adafruit Nokia 5110 LCD library

The 2nd library is Adafruit graphics library which can be downloaded from the following link
Adafruit graphics library             —->  direct link

The 3rd one is for the DHT22 sensor:
Adafruit DHT library                  —->   direct link

After the download, go to Arduino IDE —> Sketch —> Include Library —> Add .ZIP Library … and browse for the .zip file (previously downloaded).
The same thing for the other library files.

The previous 3 libraries (and Arduino SPI library) are included in the main code as follows:

Definition of sensor type, its data pin connection and the initialization of the DHT library:

Rest of code is described through comments.

Full Arduino code:


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