The DHT11 Sensor Module is a digital temperature and humidity sensor designed to provide accurate readings of environmental conditions. It outputs data in a digital format, making it easy to interface with microcontrollers such as Arduino, Raspberry Pi, and other development boards. The DHT11 is widely used in applications such as weather monitoring, home automation, and HVAC systems due to its simplicity, low cost, and reliable performance.
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 digital signal |
The DHT11 Sensor Module typically has 3 or 4 pins, depending on the module design. Below is the pinout for a common 3-pin module:
Pin | Name | Description |
---|---|---|
1 | VCC | Power supply pin (3.3V to 5.5V) |
2 | DATA | Digital data output pin |
3 | GND | Ground pin |
For a 4-pin module, the additional pin is usually a "NC" (Not Connected) pin and can be ignored.
Connect the Pins:
VCC
pin to a 3.3V or 5V power supply.GND
pin to the ground of your circuit.DATA
pin to a digital input pin on your microcontroller. Use a 10kΩ pull-up resistor between the DATA
pin and VCC
to ensure stable communication.Include a Library:
DHT
library simplifies communication with the sensor. Install the library via the Arduino IDE Library Manager.Write the Code:
// Include the DHT library
#include <DHT.h>
// Define the pin connected to the DATA pin of the DHT11 sensor
#define DHTPIN 2
// Define the type of DHT sensor (DHT11 in this case)
#define DHTTYPE DHT11
// Initialize the DHT sensor
DHT dht(DHTPIN, DHTTYPE);
void setup() {
// Start the serial communication
Serial.begin(9600);
Serial.println("DHT11 Sensor Module Test");
// Initialize the DHT sensor
dht.begin();
}
void loop() {
// Wait a few seconds between measurements
delay(2000);
// Read humidity and temperature
float humidity = dht.readHumidity();
float temperature = dht.readTemperature();
// 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");
}
DATA
pin to ensure reliable communication.No Data or Incorrect Readings:
DATA
pin is connected to the correct digital input pin on the microcontroller.DATA
pin and VCC
."Failed to Read from DHT Sensor" Error:
Unstable or Fluctuating Readings:
VCC
and GND
to stabilize the power supply.Q: Can the DHT11 measure negative temperatures?
A: No, the DHT11 can only measure temperatures in the range of 0°C to 50°C. For wider temperature ranges, consider using the DHT22 sensor.
Q: Can I use the DHT11 outdoors?
A: The DHT11 is not designed for outdoor use. Prolonged exposure to extreme conditions may damage the sensor or reduce its accuracy.
Q: What is the maximum cable length for the DHT11?
A: The maximum cable length depends on the pull-up resistor value and environmental noise. For reliable communication, keep the cable length under 20 meters and use a 10kΩ pull-up resistor.
Q: How do I know if my DHT11 sensor is faulty?
A: If the sensor consistently fails to provide valid readings despite correct wiring and code, it may be faulty. Replace the sensor to confirm.