Arduino - DHT22 - OLED
In this tutorial, we are going to learn how to read the temperature and humidity from DHT22 module and display it on an OLED.
Hardware Required
Or you can buy the following kits:
| 1 | × | DIYables STEM V3 Starter Kit (Arduino included) | |
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some links direct to products from our own brand, DIYables .
About OLED display, DHT22 Temperature Humidity Sensor
If you do not know about OLED display, and DHT22 temperature humidity sensor (pinout, how it works, how to program ...), learn about them in the following tutorials:
- Arduino - OLED tutorial
- Arduino - DHT22 tutorial
Wiring Diagram

This image is created using Fritzing. Click to enlarge image
Module wires and thick wires often do not sit well in the female headers. A Screw Shield V2 or a Proto Screw Terminal Block Shield solves this. Plug it into the Arduino and screw the wires in. The wiring stays the same. Only the wires now go to the screw terminals, as shown below.

This image is created using Fritzing. Click to enlarge image
Arduino Code - DHT22 Sensor - OLED
Quick Steps
- Open Arduino IDE on your PC.
- Navigate to the Libraries icon on the left bar of the Arduino IDE.
- Search “SSD1306”, then find the SSD1306 library by Adafruit
- Click Install button to install the library.

- You will be asked for intalling some other library dependencies
- Click Install All button to install all library dependencies.

- Search “DHT”, then find the DHT sensor library by Adafruit
- Click Install button to install the library.

- You will be asked for intalling some other library dependencies
- Click Install All button all library dependencies.

- Copy the above code and open with Arduino IDE
- Click Upload button on Arduino IDE to upload code to Arduino
- Put the sensor on hot and cold water, or grasp the sensor by your hand
- See the result on OLED and Serial Monitor
※ NOTE THAT:
The about code automatically horizontal and vertical center aligns the text on OLED display
Video Tutorial
We are considering to make the video tutorials. If you think the video tutorials are essential, please subscribe to our YouTube channel to give us motivation for making the videos.