

The DHT11 is a digital temperature and humidity sensor that provides accurate readings of temperature in Celsius and humidity in percentage. It is a low-cost, easy-to-use sensor that outputs calibrated digital signals, making it ideal for a wide range of applications. The DHT11 is commonly used in weather stations, HVAC systems, greenhouses, and other projects requiring environmental monitoring.








The DHT11 sensor is designed for simplicity and reliability. Below are its key technical specifications:
The DHT11 sensor has four pins, but only three are typically used. 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 |
Below is an example of how to use the DHT11 sensor with an Arduino UNO. This code uses the popular DHT library.
// Include the DHT library
#include <DHT.h>
// Define the pin where the DHT11 is connected
#define DHTPIN 2 // Connect DATA pin to digital pin 2
// Define the type of DHT sensor
#define DHTTYPE DHT11 // Specify DHT11 sensor
// 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() {
// Wait a second between readings
delay(1000);
// Read temperature and humidity
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");
}
No Data Output:
Invalid Readings (e.g., NaN):
dht.begin() function is called in the setup.Slow Response:
Inaccurate Measurements:
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: What is the maximum cable length for the DHT11?
A: The recommended maximum cable length is 20 meters, but shorter lengths are preferred to avoid signal degradation.
Q: How does the DHT11 compare to the DHT22?
A: The DHT22 offers a wider temperature and humidity range with higher accuracy but is more expensive. The DHT11 is sufficient for basic applications.
Q: Can I use multiple DHT11 sensors in one project?
A: Yes, you can use multiple sensors by connecting each DATA pin to a separate digital pin on the microcontroller.