The DHT11 Sensor Module is a digital temperature and humidity sensor designed to provide accurate readings of environmental conditions. It features a calibrated digital signal output and communicates via a single-wire protocol, making it easy to interface with microcontrollers. The DHT11 is widely used in applications such as weather stations, HVAC systems, and home automation projects due to its reliability and simplicity.
The DHT11 Sensor Module has the following key technical specifications:
Parameter | Value |
---|---|
Operating Voltage | 3.3V to 5.5V |
Operating Current | 0.3mA (measuring), 60µA (standby) |
Temperature Range | 0°C to 50°C |
Temperature Accuracy | ±2°C |
Humidity Range | 20% to 90% RH |
Humidity Accuracy | ±5% RH |
Sampling Period | ≥1 second |
Communication Protocol | Single-wire |
The DHT11 Sensor Module typically has three or four pins, depending on the module design. Below is the pin configuration:
Pin | Name | Description |
---|---|---|
1 | VCC | Power supply pin. Connect to 3.3V or 5V. |
2 | DATA | Digital data pin. Used for communication with the microcontroller. |
3 | NC (or GND) | Not connected (on some modules) or Ground pin. Connect to GND if labeled as GND. |
4 | GND | Ground pin. Connect to the ground of the power supply. |
Note: Some DHT11 modules include a pull-up resistor on the DATA pin. If your module does not, you may need to add an external 10kΩ pull-up resistor.
Below is an example of how to use the DHT11 with an Arduino UNO. This code reads temperature and humidity data and displays it on the Serial Monitor.
#include "DHT.h" // Include the DHT library
#define DHTPIN 2 // Pin connected to the DATA pin of the DHT11
#define DHTTYPE DHT11 // Define the sensor type (DHT11)
DHT dht(DHTPIN, DHTTYPE); // Initialize the DHT sensor
void setup() {
Serial.begin(9600); // Start the Serial Monitor at 9600 baud
Serial.println("DHT11 Sensor Initialization...");
dht.begin(); // Initialize the DHT sensor
}
void loop() {
delay(2000); // Wait 2 seconds between readings
float humidity = dht.readHumidity(); // Read humidity
float temperature = dht.readTemperature(); // Read temperature in Celsius
// Check if the readings are valid
if (isnan(humidity) || isnan(temperature)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// Print the results to the Serial Monitor
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");
}
No Data or Incorrect Readings:
"Failed to read from DHT sensor!" Error:
DHT11
) is correctly defined in the code.Inconsistent Readings:
Q: Can the DHT11 measure negative temperatures?
A: No, the DHT11 can only measure temperatures in the range of 0°C to 50°C.
Q: What is the maximum cable length for the DHT11?
A: The recommended maximum cable length is 20 meters. However, for longer distances, use a lower pull-up resistor value (e.g., 4.7kΩ) to maintain signal integrity.
Q: Can I use the DHT11 with a 3.3V microcontroller?
A: Yes, the DHT11 operates within a voltage range of 3.3V to 5.5V, making it compatible with 3.3V microcontrollers.
Q: How do I improve the accuracy of the DHT11?
A: Place the sensor in a stable environment, away from heat sources, direct sunlight, or high humidity fluctuations. For higher accuracy, consider using the DHT22 sensor, which offers better precision.