ESP32 S3 - DHT11 - OLED
The DHT11 sensor paired with an SSD1306 OLED display gives the ESP32 S3 a compact, self-contained environmental monitoring station that renders live temperature and humidity readings on a crisp 128×64 screen without any Serial Monitor connection. This tutorial walks you through wiring both components to the ESP32 S3 and writing the Arduino code that reads the sensor and updates the display every two seconds.
What you'll build:
- A circuit connecting a DHT11 temperature and humidity sensor and an SSD1306 OLED display to the ESP32 S3
- A sketch that reads temperature and humidity from the DHT11 and renders them centered on the OLED every two seconds
- A portable, stand-alone environmental monitor that works without a connected laptop
- A foundation you can extend into climate control systems, data loggers, or IoT weather stations

Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables ESP32 S3 Starter Kit (ESP32 S3 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 DHT11 and OLED
The DHT11 sensor uses a single-wire digital protocol to deliver calibrated temperature readings from 0 to 50 °C and relative humidity readings from 20 to 90 % RH, making it an accessible and affordable choice for indoor environmental monitoring projects. Pairing it with an SSD1306 OLED display gives the ESP32 S3 a sharp, high-contrast output that updates continuously without requiring a laptop or Serial Monitor to be attached.
Key Specifications
We have dedicated tutorials covering each component in depth. Each tutorial contains detailed information and step-by-step instructions about hardware pinout, working principle, wiring connection to the ESP32 S3, and Arduino code. Learn more about them at the following links:
Wiring Diagram
Connect the DHT11 sensor and the SSD1306 OLED display to your ESP32 S3 following the diagram below, and double-check every connection before powering the board. The DHT11 can operate at either 3.3 V or 5 V, so you may connect its VCC pin to either rail depending on your setup.

This image is created using Fritzing. Click to enlarge image
A screw terminal keeps each wire tight, even when the board shakes. A Screw Terminal Block for ESP32 S3 solves this. Plug the ESP32 S3 into it and screw the wires in. Below is the wiring diagram with the screw terminal board.

This image is created using Fritzing. Click to enlarge image
A GPIO Breakout Board for ESP32 S3 works too. Besides one S, 3.3V and GND pin for each GPIO, it has extra 3.3V and 5V pins:

This image is created using Fritzing. Click to enlarge image
Safety Notes
Always verify that the DHT11 data pin is connected to the GPIO defined in the sketch, and use a 10 kΩ pull-up resistor between the data pin and VCC if your module does not already include one. Keep the sensor away from heat sources, direct sunlight, and condensation, as these can skew readings and permanently damage the sensing element.
| Component | Pin | ESP32 S3 Pin |
|---|---|---|
| DHT11 Sensor | VCC | 3.3V or 5V |
| DHT11 Sensor | GND | GND |
| DHT11 Sensor | DATA | GPIO1 |
| OLED Display | VCC | 3.3V |
| OLED Display | GND | GND |
| OLED Display | SCL | GPIO9 (I2C Clock) |
| OLED Display | SDA | GPIO8 (I2C Data) |
ESP32 S3 Code - DHT11 Sensor - OLED
The following code reads temperature and humidity from the DHT11 sensor every two seconds and renders the values centered both horizontally and vertically on the SSD1306 OLED display. It uses the Adafruit DHT library for sensor communication and the Adafruit SSD1306 library for display output, keeping both initialization and update logic concise and easy to follow.
Detailed Instructions
- New to ESP32 S3? Complete our Getting Started with ESP32 S3 guide first.
- Wire the DHT11 sensor and OLED display to the ESP32 S3 following the wiring diagram above.
- Connect the ESP32 S3 board to your PC using a USB Type-C cable.
- Open Arduino IDE on your PC.
- Select the correct ESP32 S3 board and COM port from the Tools menu.
- Click the Libraries icon on the left bar of the Arduino IDE.
- Type "SSD1306" in the search box, then look for the SSD1306 library by Adafruit.
- Click the Install button to install the library.
- Search for Adafruit SSD1306 created by Adafruit and click the Install button.
- A window appears asking you to install dependencies for the library.
- Click Install All to install all required dependencies.
- Type "DHT" in the search box, then look for the DHT sensor library by Adafruit.
- Click the Install button to install the library.
- Search for DHT sensor library created by Adafruit and click the Install button.
- A window appears asking you to install dependencies for the library.
- Click Install All to install all required dependencies.
- Copy the above code and paste it into Arduino IDE.
- Click the Upload button to compile and upload the code to your ESP32 S3.

- Place the sensor near a warm cup of coffee or breathe gently on it to change the humidity.
- Watch the temperature and humidity readings update on the OLED display every two seconds.
- Pro Tip: The code automatically centers the text both horizontally and vertically on the OLED. If the display shows nothing, verify the I2C address in the code matches your module (try 0x3C or 0x3D) and confirm that SDA and SCL wires are not swapped.
Serial Monitor Output
The following Serial Monitor output shows the ESP32 S3 reading temperature and humidity from the DHT11 sensor and updating the OLED at regular two-second intervals. Each line is timestamped so you can verify the update rate and observe how readings respond to changes in the environment.
Application and Project Ideas
Once you have live temperature and humidity readings appearing on the OLED with your ESP32 S3, you can adapt this project into a wide range of practical applications across home automation, agriculture, and industrial monitoring.
- Indoor climate monitor: Mount the sensor in a room and display temperature and humidity at a glance on the OLED to ensure comfortable living conditions.
- Greenhouse controller: Trigger fans or misters automatically when the displayed humidity or temperature exceeds a set threshold.
- Server room monitor: Track temperature and humidity inside a cabinet and activate an alert if either value goes out of range.
- Plant care assistant: Display soil-adjacent humidity readings to remind users when conditions are too dry for sensitive houseplants.
- Data logger: Combine the OLED display with SD card logging so readings are both shown in real time and saved for later analysis.
- IoT weather station: Add Wi-Fi to the project so the ESP32 S3 publishes readings to a cloud dashboard while still showing them locally on the OLED.
Video Tutorial
Watch the step-by-step video walkthrough for this ESP32 S3 project below.
Challenge Yourself
Now that you can display live temperature and humidity readings on the OLED with your ESP32 S3, try these progressively harder challenges to deepen your understanding and extend the project into something more capable.
- Beginner: Modify the sketch to show temperature in both Celsius and Fahrenheit by alternating between the two units every four seconds.
- Beginner: Add a custom icon or bitmap to the OLED alongside the sensor readings to give the display a more polished, product-like appearance.
- Intermediate: Implement a simple threshold alert that flashes the OLED and prints a warning when humidity exceeds 80 %.
- Intermediate: Apply a three-sample rolling average to both temperature and humidity readings to smooth out sensor jitter on the display.
- Advanced: Add a push button that lets the user toggle between Celsius and Fahrenheit mode, storing the preference in flash memory so it survives a power cycle.
- Advanced: Extend the project with Wi-Fi so the ESP32 S3 sends readings to an MQTT broker while simultaneously updating the OLED, enabling remote monitoring from any device on the network.