ESP32 S3 UNO - DHT11 Temperature Humidity Sensor - OLED
This ESP32 S3 Uno DHT11 OLED tutorial shows you how to build a small weather station that shows temperature and humidity on a screen. You will wire a DHT11 temperature humidity sensor module and an SSD1306 OLED display to the ESP32 S3 Uno form board. The board reads the sensor and shows both values in the middle of the OLED.
In this tutorial, you will:
- Wire a DHT11 module and an I2C OLED display to the ESP32 S3 Uno
- Install the Adafruit SSD1306 and DHT sensor libraries in Arduino IDE
- Read temperature and humidity from the DHT11 with Arduino code
- Show both values on an OLED display, centered on the screen

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 .
Buy Note: If you want a bigger OLED display, use the 2.42 inch OLED Display 128x64 .
Overview of OLED display, DHT11 Temperature Humidity Sensor
This project puts two parts together. The DHT11 measures the air temperature and humidity, and the OLED shows the values, so you can read them without a computer. If one of these parts is new to you, learn it alone first. The tutorials below explain the pinout, how each part works, and how to program it.
- ESP32 S3 Uno - OLED tutorial
- ESP32 S3 Uno - DHT11 tutorial
How the project works
The DHT11 is a digital sensor. It sends temperature and humidity over one data wire, and the DHT library turns the data into degrees Celsius and percent.
The OLED display talks to the ESP32 S3 Uno over I2C, with only two signal wires (SDA and SCL). The code writes the temperature on the top line and the humidity on the bottom line, both in the center of the screen.
ESP32 S3 Uno Pinout
The image below shows the pinout of the ESP32 S3 Uno form board. Use it to find the D2, SDA and SCL header pins and their GPIO numbers when you wire the circuit.

Wiring Diagram
The DHT11 data wire goes to D2. The OLED display uses the SDA and SCL header pins. Both parts run fine from the 3.3V pin.

This image is created using Fritzing. Click to enlarge image
| Component Pin | ESP32 S3 Uno Pin |
|---|---|
| DHT11 VCC (+) | 3.3V |
| DHT11 GND (-) | GND |
| DHT11 DATA (OUT) | D2 (GPIO18) |
| OLED VCC | 3.3V |
| OLED GND | GND |
| OLED SDA | SDA (GPIO8) |
| OLED SCL | SCL (GPIO9) |
The DHT11 module already has a pull-up resistor on its board, so you need no extra parts. If you use the bare 4-pin DHT11 sensor, add a 10 kΩ resistor between DATA and 3.3V.
WARNING
The ESP32 S3 Uno pins are NOT 5V tolerant. Power the DHT11 module from 3.3V, not 5V. Then its DATA line never goes above 3.3V.
※ NOTE THAT:
On the ESP32 S3 Uno, A4 and A5 are NOT I2C pins. Always connect the OLED to the SDA (GPIO8) and SCL (GPIO9) header pins.
ESP32 S3 Uno Code - DHT11 Sensor - OLED
The sketch reads the humidity and the temperature from the DHT11 in every loop. It turns each number into text with one decimal place, prints both to the Serial Monitor, and shows them on two lines in the center of the OLED. If a reading fails, the screen shows "Failed". The sensor pin is 18, which is the GPIO number of header D2.
Detailed Instructions
- New to the ESP32 S3 Uno? Follow ESP32 S3 Uno - Getting Started first.
- Wire it up as shown in the diagram.
- Connect the board to your computer with a USB Type-C cable.
- Open Arduino IDE, choose the ESP32S3 Dev Module board and the correct COM port.
- Open the Library Manager by clicking the Libraries icon on the left side of the Arduino IDE.
- Search for "SSD1306" and find the SSD1306 library by Adafruit.
- Click Install to add the library.
- Search for Adafruit SSD1306 created by Adafruit and click the Install button.
- Install the dependencies. The IDE asks for extra libraries. Click the Install All button.
- Search for "DHT" and find the DHT sensor library by Adafruit.
- Click Install to add the DHT library.
- Search for DHT sensor library created by Adafruit and click the Install button.
- Install the dependencies. The IDE asks for the Adafruit Unified Sensor library. Click the Install All button.
- Copy the code above and paste it into the Arduino IDE.
- Upload the code by clicking the Upload button.
- Change the readings. Hold the sensor in your hand, or put it near something warm or cold.
- Check the result on the OLED screen and in the Serial Monitor at 9600 baud.
- Tip: if you use the 128x32 OLED, change SCREEN_HEIGHT to 32 and use a smaller text size, so both lines fit on the screen.
※ NOTE THAT:
The code puts the text in the middle of the OLED, both across and down. You do not need to set the position by hand.
Video Tutorial
Watch the video below to see this ESP32 S3 Uno project step by step.
FAQ
Why does the code use pin 18 and not 2?
The board has Uno header labels, but the code uses GPIO numbers. Header D2 is GPIO18 on the ESP32 S3 Uno. So DHT11_PIN is 18.
Can I power the DHT11 from 3.3V on the ESP32 S3 Uno?
Yes. The DHT11 works from 3.3V to 5.5V, so 3.3V is fine. It is also the safe choice, because the ESP32 S3 Uno pins are not 5V tolerant. If you power the module from 5V, its DATA line can reach 5V and harm the board.
Can I connect the OLED to A4 and A5 like on the UNO R4?
No. On the ESP32 S3 Uno, A4 and A5 are only analog pins. The I2C bus is on the SDA (GPIO8) and SCL (GPIO9) header pins, and Wire.begin() uses them by default.
Why does the OLED show "Failed"?
The board could not get data from the DHT11. Check the DATA wire on D2, the GND wire, and the power. A bare DHT11 sensor without a module also needs a 10 kΩ pull-up resistor between DATA and 3.3V.
Can I use a DHT22 instead of a DHT11?
Yes. The DHT22 uses the same wiring and the same library. In the code, change DHT11 to DHT22 in the DHT dht11(DHT11_PIN, DHT11); line. The DHT22 is more accurate and has a wider range.
What if my project needs more pins than the Uno headers give?
The ESP32 S3 Uno has two extra rows of holes with more GPIOs: GPIO15 and GPIO16 (I/O, PWM, analog), GPIO45 and GPIO35 to GPIO42 (I/O, PWM), and GPIO47/GPIO48 (output only, PWM). Solder pin headers to them and write the GPIO number in code. For a second DHT11 or other digital sensors, use GPIO35 to GPIO42. Do not use GPIO47/GPIO48 for a DHT11, because its data line needs input too. Be careful with two things. First, GPIO47/GPIO48 may run at 1.8V instead of 3.3V on some modules (especially ones with "V" in the name, like R8V or R16V), so 3.3V devices can be damaged or act strangely. Second, GPIO0, GPIO3 (D6), GPIO45 and GPIO46 (D9) are boot strapping pins, and a wrong connection can stop the board from booting or uploading code. Use the other extra pins first.
Troubleshooting
| Problem | Possible Cause | Solution |
|---|---|---|
| No COM port in Arduino IDE | USB driver missing or bad cable | Install the CP210x or CH340 driver, try a data USB cable, or hold BOOT while pressing RESET |
| OLED shows nothing | Wrong I2C pins or wrong address | Wire SDA to GPIO8 and SCL to GPIO9 (not A4/A5) and try address 0x3D |
| Serial Monitor shows SSD1306 allocation failed | OLED not found on the I2C bus | Check the OLED power and I2C wires, then press RESET |
| OLED shows Failed | DHT11 not answering | Check the DATA wire on D2, GND and VCC, and add a 10 kΩ pull-up for a bare sensor |
| Serial Monitor shows nan | Bad reading from the sensor | Check the wiring and make sure DHT11_PIN is 18 |
| Text does not fit on a 128x32 OLED | SCREEN_HEIGHT is still 64 and the text is too big | Set SCREEN_HEIGHT to 32 and use a smaller text size |
| Missing library error when compiling | SSD1306, GFX, DHT or Unified Sensor not installed | Install all four libraries from the Library Manager |
| Serial Monitor shows strange characters | Wrong baud rate | Set the Serial Monitor to 9600 baud |