Arduino UNO R4 - DHT22 Temperature Humidity Sensor - OLED
In this guide, we will learn how to check and show the temperature and humidity using the DHT22 module on an OLED screen.

Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables STEM V4 IoT Starter Kit (Arduino included) | |
| 1 | × | DIYables STEM V4B IoT Starter Kit (Arduino included) | |
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Buy Note: If you want a bigger OLED display, use the 2.42 inch OLED Display 128x64 .
Overview of OLED display, DHT22 Temperature Humidity Sensor
Learn about the OLED display and DHT22 temperature humidity sensor, including their pinouts, how they function, and programming methods, in the tutorials below.
- Arduino UNO R4 - OLED tutorial
- Arduino UNO R4 - DHT22 tutorial
Wiring Diagram

This image is created using Fritzing. Click to enlarge image
If you plan to keep this circuit, think about screw terminals. Put a Screw Shield V2 or a Proto Screw Terminal Block Shield on top of the Arduino UNO R4, then tighten each wire under a screw. Here is the same circuit wired through the Screw Shield V2:

This image is created using Fritzing. Click to enlarge image
See The best way to supply power to the Arduino Uno R4 and other components.
Arduino UNO R4 Code - DHT22 Sensor - OLED
Detailed Instructions
Follow these instructions step by step:
- If this is your first time using the Arduino Uno R4 WiFi/Minima, refer to the tutorial on setting up the environment for Arduino Uno R4 WiFi/Minima in the Arduino IDE.
- Connect the Arduino Uno R4 board to the DHT22 module and OLED display according to the provided diagram.
- Connect the Arduino Uno R4 board to your computer using a USB cable.
- Launch the Arduino IDE on your computer.
- Select the appropriate Arduino Uno R4 board (e.g., Arduino Uno R4 WiFi) and COM port.
- Go to the Libraries icon on the left side of the Arduino IDE.
- Search for "SSD1306" and locate the SSD13011406 library by Adafruit.
- Press the Install button to install the library.

- You need to install additional library dependencies.
- Click the Install All button to install all the required libraries.

- Search for "DHT" and look for the DHT sensor library by Adafruit.
- Click the Install button to install the library.

- You will need to install additional library dependencies.
- Click the Install All button to install all the library dependencies.

- Copy the code and open it in the Arduino IDE.
- Press the Upload button in the Arduino IDE to transfer the code to your Arduino UNO R4.
- Place the sensor in hot and cold water, or hold it in your hand.
- Check the results on the OLED display and the Serial Monitor.
※ NOTE THAT:
The code automatically centers the text horizontally and vertically on the OLED display.