Skip to content
DersTeders Log inSign up My panel

Measuring Temperature and Humidity with DHT11

Print temperature and relative humidity data from a DHT11 digital sensor to the serial port.

Circuit diagram

Measuring Temperature and Humidity with DHT11 — diagram of the arduino circuit built on a breadboard
Measuring Temperature and Humidity with DHT11 circuit breadboard layout and connections.

Interactive circuit guide

Run the simulation, follow the build steps one by one and try it in our real app.

Real screenshot of our circuit simulator Stopped
Open in our app →

Step-by-step build

Open in simulator

You can open the same circuit in the browser-based circuit simulator without any installation and inspect the wires and components there.

Parts list

ComponentQtyDescription
Arduino Uno1Reads the sensor data and sends it to the serial port.
DHT11 sensor1Measures temperature and relative humidity.
5V supply connection1Supplies voltage to the sensor's power leg.
Ground connection1Common 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

  1. Place the Arduino Uno on the work area.
    Tip: The GND pin is index 0.
  2. 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.
  3. Connect the data leg to Arduino pin 2.
    Tip: The data line goes to a single pin; no extra resistor is needed.
  4. Connect the sensor ground and the Arduino GND to common ground.
    Tip: Two wires can meet at the same ground pin.
  5. 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.

Blog · Circuit simulator · KVKK Disclosure