DHT11 Datasheet: The Digital Relative Humidity & Temperature Sensor (DHT11) Datasheet

Key Features of the DHT11 Sensor

The DHT11 sensor offers several key features that make it an attractive choice for measuring relative humidity and temperature:

  • Low cost
  • 3 to 5V power and I/O
  • 2.5mA max current use during conversion
  • Good for 20-80% humidity readings with 5% accuracy
  • Good for 0-50°C temperature readings ±2°C accuracy
  • No more than 1 Hz sampling rate (once every second)
  • Body size 15.5mm x 12mm x 5.5mm
  • 4 pins with 0.1″ spacing

DHT11 Pinout and Connections

The DHT11 has four pins:

  1. VCC: Power supply 3-5V
  2. Data out: Outputs both temperature and humidity through serial data
  3. Not used
  4. Ground

To connect the DHT11, follow these steps:

  1. Connect VCC to 3-5V power
  2. Connect GND to ground
  3. Connect the data pin to a digital pin on your microcontroller

Here is a typical wiring diagram:

+--------------+
|    DHT11     |
+--------------+
 |  +-+  +-+  |
 |  | |  | |  |  
 |  | |  | |  |
 |  |1|  |4|  |
 |  |2|  |3|  |
 |  +-+  +-+  |
 | ||| (pull-up resistor)  
 | ||| (4.7k - 10k)
 | ||| 
 | +-+
 |  |
 |  +-->  Data (Digital I/O pin)  
 +------>  VCC (3 to 5V)
  ------->  GND

How the DHT11 Measures Humidity and Temperature

The DHT11 detects water vapor by measuring the electrical resistance between two electrodes. The humidity sensing component is a moisture holding substrate with 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.

The DHT11 measures temperature with a surface mounted NTC temperature sensor (thermistor) built into the unit. To convert from analog signal to digital, the DHT11 uses an 8-bit microcontroller to output a digital signal with the temperature and humidity.

DHT11 Specifications

Here are the key specifications of the DHT11 sensor from the datasheet:

Parameter Conditions Minimum Typical Maximum Unit
Humidity
Resolution 16 16 bit
Repeatability ±1 %RH
Accuracy 25°C ±5 %RH
Interchangeability
Measurement Range 20 90 %RH
Response Time (Seconds) 1/e (63%) 6 10 15 S
Hysteresis ±1 %RH
Long-term Stability (Typical) ±1 %RH/year
Temperature
Resolution 16 16 bit
Repeatability ±1 °C
Range 0 50 °C
Response Time (Seconds) 1/e (63%) 6 10 30 S
Accuracy ±2 °C

Using the DHT11 with Arduino

To use the DHT11 with Arduino, you can use the DHT sensor library. First, install the library through the Arduino Library Manager or download it from GitHub and manually add it to your libraries folder.

Here’s a simple example sketch that prints the humidity and temperature readings to the serial monitor:

#include "DHT.h"

#define DHTPIN 2     // Digital pin connected to the DHT sensor

#define DHTTYPE DHT11   // DHT 11

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);
  Serial.println(F("DHTxx test!"));

  dht.begin();
}

void loop() {
  // Wait a few seconds between measurements.
  delay(2000);

  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit (isFahrenheit = true)
  float f = dht.readTemperature(true);

  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println(F("Failed to read from DHT sensor!"));
    return;
  }

  // Compute heat index in Fahrenheit (the default)
  float hif = dht.computeHeatIndex(f, h);
  // Compute heat index in Celsius (isFahreheit = false)
  float hic = dht.computeHeatIndex(t, h, false);

  Serial.print(F("Humidity: "));
  Serial.print(h);
  Serial.print(F("%  Temperature: "));
  Serial.print(t);
  Serial.print(F("°C "));
  Serial.print(f);
  Serial.print(F("°F  Heat index: "));
  Serial.print(hic);
  Serial.print(F("°C "));
  Serial.print(hif);
  Serial.println(F("°F"));
}

This will output something like:

Humidity: 45.00%  Temperature: 22.00°C 71.60°F  Heat index: 21.41°C 70.54°F

DHT11 Timing Diagram

One of the most important things to understand when using the DHT11 is its communication protocol. The DHT11 uses a single-wire bidirectional communication scheme. The microcontroller initiates communication by pulling the data line low for at least 18ms. This signals to the sensor that the microcontroller wants to read data.

The DHT11 responds by pulling the data line low for 80µs, followed by a high pulse for 80µs. It then starts transmitting data, sending 40 bits in total, including two 8-bit integral RH data, two 8-bit integral T data, and an 8-bit checksum. Each bit is transmitted as follows:

  • To send a ‘0’, the line is held low for 50µs, then high for 26-28µs.
  • To send a ‘1’, the line is held low for 50µs, then high for 70µs.

Here’s a timing diagram illustrating this process:

            Host (MCU)                                                  DHT11

  __       ____   ____    18ms        20-40us        80us          
 /  \     /    \ /    \__/   \______/       \_____/     \_____         
     \___ /      \         80us                 80us          \_50us_/ 0 \_27us_/ 1 \_ ...                   

The DHT11 sends 5 bytes in total:

  • Byte 1: Relative humidity integral value
  • Byte 2: Relative humidity decimal value
  • Byte 3: Temperature integral value
  • Byte 4: Temperature decimal value
  • Byte 5: Checksum

The checksum byte is the sum of the first four bytes truncated to 8 bits. You can use this to check if the transmission was successful.

FAQ

What is the DHT11 used for?

The DHT11 is a low-cost digital humidity and temperature sensor. It is commonly used in environmental monitoring systems, HVAC systems, and weather stations. Its small size and low cost make it a popular choice for hobbyists and DIY projects.

How accurate is the DHT11?

The DHT11 is reasonably accurate for its price. It has an accuracy of ±5%RH for relative humidity and ±2°C for temperature. For more demanding applications that require higher accuracy, you may want to consider the DHT22 which offers an accuracy of ±2%RH and ±0.5°C.

Why am I getting incorrect readings from my DHT11?

There are several possible reasons why you might be getting incorrect readings from your DHT11:

  1. Wiring issues: Check that your wiring matches the pinout diagram. Make sure you have the correct resistor (4.7K-10K) between VCC and the data pin.

  2. Timing issues: The DHT11 is a relatively slow sensor. You need to leave at least 2 seconds between readings. The DHT library handles this for you.

  3. Power issues: The DHT11 needs a stable power supply between 3 and 5V. Inconsistent power can lead to incorrect readings.

  4. Environmental issues: The DHT11 is sensitive to rapid changes in humidity. If you breathe on the sensor, for example, you may get temporarily high readings.

  5. Damaged sensor: If your sensor has been exposed to extreme conditions or mishandled, it may be damaged and providing incorrect data.

What’s the difference between the DHT11 and DHT22?

The DHT11 and DHT22 (also known as the AM2302) are both digital humidity and temperature sensors, but they have some key differences:

  • Accuracy: The DHT22 is more accurate, with ±2%RH humidity accuracy and ±0.5°C temperature accuracy, compared to ±5%RH and ±2°C for the DHT11.

  • Range: The DHT22 has a wider measurement range. It can measure 0 to 100%RH (compared to 20-80%RH for the DHT11) and -40 to 80°C (compared to 0-50°C for the DHT11).

  • Precision: The DHT22 provides 16-bit humidity and temperature values, compared to 8-bit values from the DHT11. This means the DHT22 gives more precise readings.

  • Size: The DHT11 is slightly smaller than the DHT22.

  • Price: The DHT11 is generally cheaper than the DHT22.

Can I use the DHT11 with a Raspberry Pi?

Yes, you can use the DHT11 with a Raspberry Pi. The process is very similar to using it with an Arduino. You can use the Adafruit DHT Python library to read data from the sensor. Here’s a simple example:

import Adafruit_DHT

# Set sensor type : Options are DHT11,DHT22 or AM2302
sensor=Adafruit_DHT.DHT11

# Set GPIO sensor is connected to
gpio=17

# Use read_retry method. This will retry up to 15 times to
# get a sensor reading (waiting 2 seconds between each retry).
humidity, temperature = Adafruit_DHT.read_retry(sensor, gpio)

if humidity is not None and temperature is not None:
    print('Temp={0:0.1f}*C  Humidity={1:0.1f}%'.format(temperature, humidity))
else:
    print('Failed to get reading. Try again!')

Remember to connect the DHT11 data pin to a GPIO pin on your Raspberry Pi, VCC to 3.3V or 5V power, and ground to ground. You also need a resistor (4.7K-10K) between VCC and the data pin.

CATEGORIES:

RF PCB

Tags:

No responses yet

Leave a Reply

Your email address will not be published. Required fields are marked *

Latest Comments

No comments to show.