ESP32 S3 UNO - DHT11
This ESP32 S3 Uno DHT11 tutorial shows you how to wire a DHT11 temperature and humidity sensor to the ESP32 S3 Uno form board and read its data with Arduino code. It works with both the bare 4-pin DHT11 sensor and the 3-pin DHT11 module. You will see the humidity and the temperature in Celsius and Fahrenheit on the Serial Monitor.
In this tutorial, you will:
- Learn the pinout of the DHT11 sensor and the DHT11 module.
- Wire the DHT11 sensor or module to the ESP32 S3 Uno.
- Install the DHT sensor library in the Arduino IDE.
- Read temperature and humidity with readTemperature() and readHumidity().

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 DHT11 Temperature and Humidity Sensor
The DHT11 is a cheap, easy sensor that measures two things at once: air temperature and relative humidity. It sends both values over a single data wire, so it uses only one pin on your board. It is slow but steady, which makes it a good fit for room monitors and simple weather projects.
| DHT11 | |
|---|---|
| Operating Voltage | 3 to 5V |
| Temperature Range | 0°C to 50°C |
| Temperature Accuracy | ± 2°C |
| Humidity Range | 20% to 80% |
| Humidity Accuracy | 5% |
| Reading Rate | 1Hz (once every second) |
Pinout
You can buy the DHT11 in two forms: a bare sensor and a small module. Knowing the pins of each one helps you wire it the right way.

DHT11 Sensor (4 pins)
The bare sensor has four pins. GND goes to ground (0V). VCC goes to the power supply (3.3V or 5V). DATA carries the readings between the sensor and the ESP32 S3 Uno. NC is not connected, so you can leave it alone.
DHT11 Module (3 pins)
The module has only three pins: GND, VCC and DATA. Some makers print them as -, + and OUT instead. GND goes to ground, VCC goes to the power supply, and DATA goes to an ESP32 S3 Uno pin.
ESP32 S3 Uno Pinout
The image below shows the pinout of the ESP32 S3 Uno form board. Use it to find the Uno header pins (D2, A0, SDA…) and their GPIO numbers while you wire the circuit.

Wiring Diagram
The DATA line of the DHT11 needs a pull-up resistor of 5K to 10K Ohms. This resistor keeps the line high when nobody is talking, so the sensor and the ESP32 S3 Uno can exchange data correctly.
ESP32 S3 Uno - DHT11 Sensor Wiring
With the bare 4-pin sensor, you add the pull-up resistor yourself, between VCC and DATA.

This image is created using Fritzing. Click to enlarge image
| DHT11 Sensor Pin | ESP32 S3 Uno Pin |
|---|---|
| VCC | 3.3V |
| DATA | D2 (GPIO18), plus 10 kΩ resistor to 3.3V |
| NC | not connected |
| GND | GND |
ESP32 S3 Uno - DHT11 Module Wiring
Most DHT11 modules already have the pull-up resistor on the board. So you only need three wires, and no extra parts.

This image is created using Fritzing. Click to enlarge image
| DHT11 Module Pin | ESP32 S3 Uno Pin |
|---|---|
| VCC (+) | 3.3V |
| DATA (OUT) | D2 (GPIO18) |
| GND (-) | GND |
WARNING
The ESP32 S3 Uno pins work at 3.3V and are NOT 5V tolerant. Power the DHT11 from 3.3V, so the pull-up resistor holds the DATA line at 3.3V. If you power the DHT11 from 5V, the DATA line goes up to 5V and can damage GPIO18.
How To Program For DHT11 Temperature Sensor
The code is the same for the sensor and the module. Only a few lines from the DHT library do all the work, so it is worth knowing each one.
- Include the library.
- Set the ESP32 S3 Uno pin that is connected to the DHT11 DATA pin. D2 on the header is GPIO18, so the code uses 18.
- Create a DHT11 sensor object.
- Start the sensor.
- Read the humidity.
- Read the temperature in Celsius.
- Read the temperature in Fahrenheit.
ESP32 S3 Uno Code - DHT11
The sketch below reads the DHT11 every three seconds. It prints the humidity and the temperature in °C and °F on one line. If a reading fails, it prints an error message instead, so you know to check the wiring.
Detailed Instructions
Follow these steps one by one:
- 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.
- Find the library: search for "DHT" and find the DHT sensor library by Adafruit.
- Install it by clicking the Install button.
- Search for DHT sensor library created by Adafruit and click the Install button.
- Install the dependencies: the IDE asks for extra libraries. Click the Install All button.
- Copy the code above and paste it into the Arduino IDE.
- Upload the code by clicking the Upload button.
- Open the Serial Monitor and set the baud rate to 9600.
- Test it: make the air around the sensor warmer or cooler, for example by holding it in your hand, and watch the values change.
- Tip: the DHT11 is slow and its values change in steps of 1°C and 1%. If you need more precision, try the DHT22 instead.
Video Tutorial
Watch the video below to see this ESP32 S3 Uno project step by step.
FAQ
Should I power the DHT11 from 3.3V or 5V on the ESP32 S3 Uno?
Use 3.3V. The DHT11 works from 3V to 5V, and at 3.3V its DATA line stays at a safe level for the ESP32 S3 Uno. The ESP32 S3 Uno pins are not 5V tolerant, so a 5V pull-up on DATA can damage the pin.
Which ESP32 S3 Uno pin can I use for the DHT11?
Almost any digital pin works. This tutorial uses D2, which is GPIO18, so the code says 18. If you move the wire, change DHT11_PIN to the GPIO number of the new pin, not the D label. Avoid D6 (GPIO3) and D9 (GPIO46) because they are boot strapping pins.
Why does the Serial Monitor show "Failed to read from DHT11 sensor!"?
The library could not get a valid answer from the sensor. Most often the DATA wire is on the wrong pin, the pull-up resistor is missing on a bare sensor, or the sensor has no power. Check the wiring and make sure DHT11_PIN matches the GPIO you used.
Is the code different from the UNO R4 code?
Only the pin number changes. The UNO R4 code uses pin 2, while the ESP32 S3 Uno code uses 18, because D2 on this board is GPIO18. The Adafruit DHT library works on both boards.
How often can I read the DHT11?
The DHT11 gives a new reading about once per second. The sketch waits three seconds between reads to keep the values stable. Reading faster does not give new data and can cause failed reads.
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 use them and write the GPIO number in code. A second DHT11 fits well on GPIO15, GPIO16 or GPIO35 to GPIO42, but not on GPIO47/GPIO48, because the DHT11 DATA line needs an input. 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 board not in upload mode | Install the CP210x or CH340 driver, use a data USB cable, or hold BOOT while you press RESET |
| Upload fails with a timeout error | Wrong board selected | Select ESP32S3 Dev Module and the correct COM port, then upload again |
| "Failed to read from DHT11 sensor!" | DATA wire on the wrong pin or loose wire | Connect DATA to D2 (GPIO18) and make sure DHT11_PIN is 18 |
| Readings fail with the bare sensor | No pull-up resistor on DATA | Add a 5K to 10K Ohm resistor between VCC and DATA |
| Board resets or pin acts strange | DHT11 powered from 5V so DATA is at 5V | Power the DHT11 from 3.3V |
| Compile error DHT.h not found | Library not installed | Install the DHT sensor library by Adafruit and the Adafruit Unified Sensor library |
| Strange characters on Serial Monitor | Wrong baud rate | Set the Serial Monitor to 9600 baud |
| Values do not change or look wrong | Reading too fast or sensor near a heat source | Keep at least 1 second between reads and move the sensor away from the board and other warm parts |