Measuring Temperature and Humidity with DHT11
Print temperature and relative humidity data from a DHT11 digital sensor to the serial port.
Circuit diagram

Bu projeyi gerçekten kurmak istersen parçaları hobidevre.com'dan temin edebilirsin →
Build it for real
To build this project for real, get the parts from hobidevre.com → hobidevre.com →
More build guides: hobidevre.com/blog
Create a free account — save your progress and get more circuits →
No installationYou can open the same circuit in the browser-based circuit simulator without any installation and inspect the wires and components there.
Parts list
| Component | Qty | Description |
|---|---|---|
| Arduino Uno | 1 | Reads the sensor data and sends it to the serial port. |
| DHT11 sensor | 1 | Measures temperature and relative humidity. |
| 5V supply connection | 1 | Supplies voltage to the sensor's power leg. |
| Ground connection | 1 | Common reference for the sensor and the board. |
Breadboard layout
The Arduino is on the left, the DHT11 at the upper right, the 5V supply on the upper row and the common ground at the lower right. The DHT11's data leg goes directly to Arduino pin 2 and its ground leg to common ground.
Step-by-step build
- Place the Arduino Uno on the work area.Tip: The GND pin is index 0.
- Connect the DHT11's power leg to 5V.Tip: The sensor's pin 0 is power, pin 1 is data and pin 2 is ground.
- Connect the data leg to Arduino pin 2.Tip: The data line goes to a single pin; no extra resistor is needed.
- Connect the sensor ground and the Arduino GND to common ground.Tip: Two wires can meet at the same ground pin.
- Add the library, upload the code and open the serial port.Tip: Wait a few seconds between readings.
How it works
The DHT11 encodes its measurement result on a single line using timing. The board first pulls the line to the supply level and waits for the sensor to respond; the first part of the incoming 40-bit sequence carries relative humidity, the second part temperature and the final part the check byte. The check byte is used to understand whether the data was corrupted during transfer. The software decodes the raw bits and converts the values into usable units. A second request made before the sensor's measurement cycle is complete may return faulty or old data; for this reason a wait between readings is necessary.
What you will learn
- Reads data from a digital sensor.
- Checks data integrity with a check byte.
- Pays attention to the sensor reading interval.
Expected result: Temperature and relative humidity values appear on the serial port at regular intervals.
Challenge
Weather station: Read temperature and humidity at regular intervals.
Goal: A temperature and humidity pair appears on the serial port.
Tips
- Bringing the sensor close to a hot surface affects the reading.
- If no data appears on the serial port, check the data pin and the common ground.
Frequently asked questions
How many legs does the DHT11 have and what are they?
It has three legs: power, data and ground. The data leg connects to a single digital pin.
Why is a wait needed between readings?
A request arriving before the sensor's measurement cycle is complete may return old or faulty data.
What should be checked if no data appears on the serial port?
The data pin, the power supply and the common ground connections should be checked.
If you want to build this project in real life, you can get the parts from hobidevre.com. For more circuit ideas, visit the hobidevre.com blog.