Arduino - Temperature Humidity Sensor - OLED Display
In this tutorial, we are going to learn:
- How to read the temperature and humidity from DHT11 sensor and display it on an OLED.
- How to read the temperature and humidity from DHT22 sensor and display it on an OLED.

Hardware Required
You can use DHT22 sensor instead of DHT11 sensor.
Or you can buy the following sensor kit:
1 | × | DIYables Sensor Kit 30 types, 69 units |
About OLED display, DHT11 and DHT22 Temperature Humidity Sensor
If you do not know about OLED display, DHT11 and DHT22 temperature humidity sensor (pinout, how it works, how to program ...), learn about them in the following tutorials:
- Arduino - OLED tutorial
Wiring Diagram
Arduino - DHT11 Module LCD Wiring

This image is created using Fritzing. Click to enlarge image
Arduino - DHT22 Module LCD Wiring

This image is created using Fritzing. Click to enlarge image
Arduino Code - DHT11 Sensor - OLED
Quick Steps
- Open Arduino IDE, Go to Tools Manage Libraries

- 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
Arduino Code - DHT22 Sensor - OLED
※ NOTE THAT:
Code for DHT11 and DHT22 are identical except for one line of code. Library for DHT11 and DHT22 are the same.
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.