

The DHT11 is a digital temperature and humidity sensor that provides accurate readings of environmental conditions. It features a single-wire digital interface, making it easy to connect to microcontrollers for data collection. The DHT11 is widely used in applications such as weather monitoring, home automation, and industrial control systems due to its simplicity and reliability.








The DHT11 sensor is designed for basic temperature and humidity sensing applications. Below are its key technical details:
The DHT11 sensor has four pins, but typically only three are used in most applications. Below is the pinout:
| Pin Number | Name | Description |
|---|---|---|
| 1 | VCC | Power supply (3.3V to 5.5V) |
| 2 | DATA | Digital data output (connect to microcontroller) |
| 3 | NC (Not Connected) | No connection (leave unconnected) |
| 4 | GND | Ground |
The DHT11 sensor is easy to use with microcontrollers like the Arduino UNO. Follow the steps below to integrate it into your project:
Below is an example of how to read temperature and humidity data from the DHT11 using an Arduino UNO. This code uses the popular DHT library.
// Include the DHT library
#include <DHT.h>
// Define the DHT sensor type and the pin it's connected to
#define DHTPIN 2 // Pin connected to the DATA pin of DHT11
#define DHTTYPE DHT11 // Specify the sensor type (DHT11)
// Initialize the DHT sensor
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600); // Start serial communication
Serial.println("DHT11 Sensor Initialization");
dht.begin(); // Initialize the DHT sensor
}
void loop() {
// Read temperature and humidity values
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 readings to the Serial Monitor
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");
delay(2000); // Wait 2 seconds before the next reading
}
No Data or Incorrect Readings:
"Failed to read from DHT sensor!" Error:
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: 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.
Q: How do I extend the cable length for the DHT11?
A: Use shielded cables and keep the length under 20 meters to avoid signal degradation.
Q: What is the difference between the DHT11 and DHT22?
A: The DHT22 offers a wider temperature and humidity range with higher accuracy, but it is more expensive than the DHT11.