ESP32 C3 Super Mini - DHT22 - OLED
This tutorial shows you how to use the ESP32 C3 Super Mini to read the temperature and humidity from a DHT22 module and display them on an OLED. You will build a small climate monitor that works without a computer once the code is uploaded.
In this tutorial, you'll learn:
- How to wire a DHT22 module and an OLED to the ESP32 C3 Super Mini
- How to install the SSD1306 and DHT libraries in Arduino IDE
- How to read temperature and humidity with the ESP32 C3 Super Mini
- How to show both values in the center of the OLED
- How to check the same readings on the Serial Monitor

Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Overview of OLED Display and DHT22 Temperature Humidity Sensor
A DHT22 is a digital sensor that measures temperature and humidity, and an OLED is a small screen that shows the result.
Key Features:
- One data wire: The DHT22 module needs only one GPIO pin
- Two readings: You get temperature and humidity from one sensor
- Easy to read: The OLED shows clear, high-contrast text
- Simple wiring: The OLED uses only two I2C signal wires
Technical Specifications:
- DHT22 voltage: 3V to 5V
- Humidity range: 0% to 100%, accuracy ±2% to 5%
- Temperature range: -40°C to 80°C, accuracy ±0.5°C
- Reading rate: 0.5Hz (one new reading every 2 seconds)
- OLED driver: SSD1306
- OLED size: 128x64 or 128x32 pixels
- OLED I2C address: 0x3C (used in the code below)
We have specific tutorials about each part. They cover the hardware pinout, how it works and how to program it:
- ESP32 C3 Super Mini - OLED 128x64 tutorial
- ESP32 C3 Super Mini - OLED 128x32 tutorial
- ESP32 C3 Super Mini - DHT22 tutorial
DHT22 Module Pinout
The DHT22 module has three pins:
- VCC (or +): Connect to 3.3V
- GND (or -): Connect to ground (0V)
- DATA (or OUT): Sends the readings to the board

OLED Pinout
The I2C OLED module has four pins:
- VCC: Power for the display
- GND: Connect to ground (0V)
- SCL: I2C clock line
- SDA: I2C data line
Wiring Diagram
Connect the DHT22 module and the OLED to the ESP32 C3 Super Mini as shown below.
- Note: The DHT22 module has a built-in pull-up resistor, so you do not need a separate one.
- Note: The built-in LED also uses GPIO8, so it may flicker while the OLED updates. This is normal.
- Note: Check every wire before you power the board.

This image is created using Fritzing. Click to enlarge image
DHT22 module connections:
| DHT22 Module Pin | ESP32 C3 Super Mini Pin |
|---|---|
| VCC | 3.3V |
| GND | GND |
| DATA | GPIO4 |
OLED connections:
| OLED Pin | ESP32 C3 Super Mini Pin |
|---|---|
| VCC | 3.3V |
| GND | GND |
| SDA | GPIO8 |
| SCL | GPIO9 |
ESP32 C3 Super Mini Code - DHT22 Sensor - OLED
The code below reads the DHT22 sensor again and again and shows the temperature and humidity on the OLED.
What This Code Does:
- Starts the OLED: Uses the default I2C pins of the board: GPIO8 (SDA) and GPIO9 (SCL)
- Starts the sensor: Uses the DHT22 data line on GPIO4
- Reads the values: Gets the humidity and the temperature in Celsius
- Builds the text: Keeps one decimal place and adds the degree symbol and "C", or the "%" sign
- Shows the result: Prints both values on the OLED and the Serial Monitor, or "Failed" on the OLED if the reading fails
※ NOTE THAT:
The above code automatically horizontal and vertical center aligns the text on OLED display.
※ NOTE THAT:
The code is set for the 128x64 OLED. If you use the 128x32 OLED, change SCREEN_HEIGHT to 32 and change oled.setTextSize(3) to oled.setTextSize(1), so that both lines fit on the screen.
Detailed Instructions
Follow these bullets to run the project on your ESP32 C3 Super Mini.
- New to ESP32 C3 Super Mini? Complete our Getting Started with ESP32 C3 Super Mini tutorial first to set up your development environment.
- Wire the parts: Connect the DHT22 module and the OLED as shown in the wiring diagram above.
- Connect the board: Connect the ESP32 C3 Super Mini to your computer with a USB Type-C cable.
- Open Arduino IDE: Start Arduino IDE on your computer.
- Select the board: Make sure ESP32 C3 Super Mini is selected in Tools > Board.
- Select the port: Choose the COM port of your board.
- Open Libraries: Click the Libraries icon on the left bar of the Arduino IDE.
- Find the OLED library: Search “SSD1306”, then find the SSD1306 library by Adafruit.
- Install it: Click the Install button to install the library.

- Add the extras: You will be asked to install some other library dependencies. Click the Install All button to install them.

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

- Add the extras: You will be asked to install some other library dependencies. Click the Install All button to install them.

- Copy the code: Copy the above code and open it with Arduino IDE.
- Upload the code: Click the Upload button to upload the code to your ESP32 C3 Super Mini.

- Test the sensor: Hold the sensor in your hand or breathe gently on it. Keep it dry, because the DHT22 is not waterproof.
- Read the OLED: See the result on the OLED.
- Open Serial Monitor: Click the Serial Monitor icon and set the baud rate to 115200 to see the same result.

- Pro Tip: If the OLED shows "Failed", the board cannot read the sensor. Check the DATA wire on GPIO4 and the power wires.
Serial Monitor Output
Each reading prints one line with the temperature and the humidity. The same line can repeat many times, because the sensor gives a new reading only every 2 seconds and the code has no delay.
Application and Project Ideas
This ESP32 C3 Super Mini DHT22 and OLED project is a good base for many small builds.
- Room climate monitor: Show the temperature and humidity on your desk.
- Greenhouse display: Check the air near your plants at a glance.
- Plant care helper: See when the air is too dry for your houseplants.
- Storage checker: Watch the humidity in a cupboard or a tool box.
- Server cabinet monitor: Keep an eye on the air inside a small cabinet.
Challenge Yourself
Ready for more? Try these ESP32 C3 Super Mini challenges.
- Easy: Show the temperature in Fahrenheit instead of Celsius.
- Easy: Add delay(2000) to the loop so the Serial Monitor prints one line every 2 seconds.
- Medium: Keep the lowest and highest temperature and show them on the OLED.
- Medium: Add a buzzer that beeps when the humidity gets too high.
- Advanced: Draw a small graph of the last humidity readings on the OLED.