Browse over 10,000 Electronics Projects using the Page Numbering provided at the bottom of each Page.

# How to Set Up the DHT11 Humidity Sensor on an Arduino

Scott Campbell from Circuitbasics.com has set up this temperature and humidity sensor using an Arduino and DHT11 sensors.

Because of their low cost and small size, DHT11 humidity and temperature sensors are perfect for lots of different DIY electronics projects. Some projects where the DHT11 would be useful include remote weather stations, home environment control systems, and agricultural/garden monitoring systems. The DHT11 is a digital sensor that lets you easily get relative humidity and temperature readings in your projects. In this post, I’ll first go into a little background on what humidity is, then I’ll explain how the DHT11 measures humidity. After that, I’ll show you how to connect the DHT11 to the Arduino and give you some example code so you can use the DHT11 in your own projects.

DHT11 Technical Specifications:

• Humidity Range: 20-90% RH
• Humidity Accuracy: ±5% RH
• Temperature Range: 0-50 °C
• Temperature Accuracy: ±2% °C
• Operating Voltage: 3V to 5.5V

## What is Relative Humidity?

The DHT11 humidity and temperature sensor measures relative humidity (RH) and temperature. Relative humidity is the ratio of water vapor in air vs. the saturation point of water vapor in air. The saturation point of water vapor in air changes with temperature. Cold air can hold less water vapor before it is saturated, and hot air can hold more water vapor before it is saturated. The formula for relative humidity is as follows:

Relative Humidity = (density of water vapor / density of water vapor at saturation) x 100%

Basically, relative humidity is the amount of water in the air compared to the amount of water that air can hold before condensation occurs. It’s expressed as a percentage.  For example, at 100% RH condensation (or rain) occurs, and at 0% RH, the air is completely dry.

## How the DHT11 Measures Humidity and Temperature

The DHT11 calculates relative humidity by measuring the electrical resistance between two electrodes. The humidity sensing component of the DHT11 is a moisture holding substrate (usually a salt or conductive plastic polymer) with the electrodes applied to the surface. When water vapor is absorbed by the substrate, ions are released by the substrate which increases the conductivity between the electrodes. The change in resistance between the two electrodes is proportional to the relative humidity. Higher relative humidity decreases the resistance between the electrodes while lower relative humidity increases the resistance between the electrodes. Inside the DHT11 you can see electrodes applied to a substrate on the front of the chip:

The DHT11 converts the resistance measurement to relative humidity on an IC mounted to the back of the unit and transmits the humidity and temperature readings directly to the Arduino. This IC also stores the calibration coefficients and controls the data signal transmission between the DHT11 and the Arduino:

The temperature readings from the DHT11 come from a surface mounted NTC temperature sensor (thermistor) built into the unit. To learn more about thermistors and how to use them on the Arduino, check out our Arduino Thermistor Temperature Sensor Tutorial.

The DHT11 uses one signal wire to transmit sensor readings to the Arduino digitally. The power comes from separate 5V and ground wires. A 5K – 10K Ohm pull-up resistor is connected from the signal line to 5V to make sure the signal level stays high by default (see the data sheet for specifics on how the signal is sent).

There are two different variations of the DHT11 sensor you might come across. One type has four pins, and the other type is mounted to a small PCB that has three pins. The PCB mounted version with three pins is nice since it includes a surface mounted 10K Ohm pull-up resistor for the signal line:

## How to Set Up the DHT11 on an Arduino

The DHT11 is really easy to connect to the Arduino:

## Code for Serial Monitor Output of Readings

Before we can use the DHT11 on the Arduino, we need to install the DHTLib library, which contains all of the functions we will need to get the humidity and temperature readings from the sensor. It’s easy to install. Just download the DHTLib.zip file below, and open up the Arduino IDE. Then go to Sketch>Include Library>Add Library and select the DHTLib.zip file.

All pictures and videos are courtesy of Scott Campbell. Thank you Scott.