

The DHT11 is a widely used digital temperature and humidity sensor that provides reliable and accurate readings with a dedicated NTC temperature sensor and a capacitive humidity sensor. It is a basic and low-cost sensor that is suitable for hobbyist and educational projects. The DHT11 is commonly used in weather stations, home environmental control systems, and IoT applications where monitoring of ambient temperature and humidity is required.








| Pin Number | Name | Description |
|---|---|---|
| 1 | VCC | Power supply (3 to 5.5 VDC) |
| 2 | DATA | Digital data output |
| 3 | NC | Not connected |
| 4 | GND | Ground |
#include "DHT.h"
#define DHTPIN 2 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
// Wait a few seconds between measurements.
delay(2000);
// Reading temperature or humidity takes about 250 milliseconds!
float humidity = dht.readHumidity();
float temperature = dht.readTemperature();
// Check if any reads failed and exit early (to try again).
if (isnan(humidity) || isnan(temperature)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// Compute heat index in Celsius (isFahrenheit = false)
float heatIndex = dht.computeHeatIndex(temperature, humidity, false);
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.print("% Temperature: ");
Serial.print(temperature);
Serial.print("°C Heat index: ");
Serial.print(heatIndex);
Serial.println("°C");
}
Note: The above code uses the DHT sensor library, which can be installed via the Arduino Library Manager.
Q: Can the DHT11 sensor be used outdoors? A: Yes, but it should be protected from direct sunlight, rain, and condensation for accurate measurements.
Q: How long does the DHT11 sensor last? A: The DHT11 has a typical lifespan of 3-5 years, depending on usage conditions.
Q: Is calibration required for the DHT11 sensor? A: The DHT11 comes pre-calibrated from the factory and does not typically require additional calibration.
Q: Can I use the DHT11 sensor with a 3.3V supply? A: Yes, the DHT11 can operate with a supply voltage from 3 to 5.5 VDC.
For further assistance, consult the datasheet provided by the manufacturer or contact technical support.