Introduction to the DHT11 Sensor
The DHT11 is a popular, low-cost digital sensor that measures relative humidity and temperature. It utilizes a capacitive humidity sensor and a thermistor to measure the surrounding air, providing a digital signal output. The sensor is widely used in various applications, such as environmental monitoring, weather stations, and home automation systems.
Key Features of the DHT11 Sensor
- Relative humidity measurement range: 20-90% RH
- Temperature measurement range: 0-50°C
- Humidity accuracy: ±5% RH
- Temperature accuracy: ±2°C
- Low power consumption: 2.5mA max current use during conversion
- Small size: 15.5mm x 12mm x 5.5mm
- Single-bus data communication protocol
- 4-pin package for easy integration
DHT11 Sensor Specifications
Electrical Characteristics
Parameter | Condition | Min | Typical | Max | Unit |
---|---|---|---|---|---|
Supply Voltage | – | 3 | 5 | 5.5 | V |
Supply Current | Measuring | 0.5 | – | 2.5 | mA |
Average | 0.2 | – | 1 | mA | |
Standby | 100 | – | 150 | μA | |
Sampling period | – | 1 | – | 10 | s |
Relative Humidity Measurement
Parameter | Condition | Min | Typical | Max | Unit |
---|---|---|---|---|---|
Resolution | – | – | – | 1 | %RH |
Range | – | 20 | – | 90 | %RH |
Accuracy | 25°C | – | – | ±5 | %RH |
Interchangeability | – | – | – | ±1 | %RH |
Long-term Stability | – | – | – | ±1 | %RH/year |
Temperature Measurement
Parameter | Condition | Min | Typical | Max | Unit |
---|---|---|---|---|---|
Resolution | – | – | – | 1 | °C |
Range | – | 0 | – | 50 | °C |
Accuracy | 25°C | – | – | ±2 | °C |
DHT11 Sensor Pinout and Connections
The DHT11 sensor has a 4-pin package with the following pinout:
- VCC: Power supply (3.5-5.5V)
- DATA: Serial data output
- NC: Not connected
- GND: Ground
To connect the DHT11 sensor to a microcontroller, follow these steps:
- Connect VCC to the power supply (3.5-5.5V)
- Connect DATA to a digital I/O pin of the microcontroller
- Connect a 10kΩ pull-up resistor between VCC and DATA
- Connect GND to the ground of the microcontroller
DHT11 Communication Protocol
The DHT11 uses a single-bus communication protocol to transmit data. The communication process is initiated by the microcontroller (master) sending a start signal. The sensor (slave) responds with a specific sequence of pulses, indicating that it is ready to send data.
Data Format
The data transmitted by the DHT11 consists of 40 bits:
- 8 bits of integral relative humidity data
- 8 bits of decimal relative humidity data
- 8 bits of integral temperature data
- 8 bits of decimal temperature data
- 8 bits of checksum
The checksum is used to verify the integrity of the received data. It is calculated by summing the first four bytes of data and comparing the least significant 8 bits of the result with the received checksum byte.
Timing Diagram
The timing diagram for the DHT11 communication protocol is as follows:
____ ________
| | | |
| | | |
| |_______| |________
18ms 20-40μs
- The microcontroller sends a start signal by pulling the DATA line low for at least 18ms.
- The microcontroller then pulls the DATA line high and waits for 20-40μs.
- The DHT11 responds by pulling the DATA line low for 80μs and then high for 80μs.
- The DHT11 sends 40 bits of data, with each bit transmitted as follows:
- LOW for 50μs
- HIGH for 26-28μs (bit ‘0’) or 70μs (bit ‘1’)
Interfacing DHT11 with Arduino
To interface the DHT11 sensor with an Arduino, you can use the DHT library by Adafruit. Here’s a simple example sketch:
#include <DHT.h>
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
delay(2000);
float humidity = dht.readHumidity();
float temperature = dht.readTemperature();
if (isnan(humidity) || isnan(temperature)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.print("%\tTemperature: ");
Serial.print(temperature);
Serial.println("°C");
}
Frequently Asked Questions (FAQ)
-
Q: What is the accuracy of the DHT11 sensor?
A: The DHT11 has an accuracy of ±5% RH for relative humidity and ±2°C for temperature. -
Q: What is the operating voltage of the DHT11?
A: The DHT11 can operate with a supply voltage between 3.5V and 5.5V. -
Q: How often can I read data from the DHT11?
A: The DHT11 has a maximum sampling rate of once every 1 second. -
Q: Can I use the DHT11 in outdoor applications?
A: While the DHT11 can be used outdoors, it is not recommended for prolonged exposure to extreme conditions. For outdoor applications, consider using the more robust DHT22 sensor. -
Q: How do I calculate the checksum for the DHT11 data?
A: The checksum is calculated by summing the first four bytes of the received data (humidity and temperature values) and comparing the least significant 8 bits of the result with the received checksum byte.
Conclusion
The DHT11 is a versatile and affordable sensor for measuring relative humidity and temperature in various applications. By understanding its specifications, communication protocol, and interfacing methods, you can easily integrate the DHT11 into your projects and build powerful environmental monitoring systems.
Leave a Reply