What is the DHT11 Sensor?
The **DHT11** is an ultra low-cost digital temperature and humidity sensor. It uses a capacitive humidity sensing element and a thermistor to measure the surrounding air, outputting a calibrated digital signal on a single data pin — no analog inputs required!
DHT11 vs DHT22 — Which to Choose?
|---|---|---|
**Verdict**: Use DHT11 for learning and basic projects. Choose DHT22 for weather stations or projects requiring higher precision and sub-zero temperature monitoring.
Building an IoT Dashboard with ESP32
Connect the DHT11 to an **ESP32** to publish real-time temperature and humidity telemetry:
**ESP32 Connections:**
- DHT11 DATA → GPIO 4
- DHT11 VCC → 3.3V
- DHT11 GND → GND
#include <WiFi.h>
#include <DHT.h>
#define DHT_PIN 4
#define DHT_TYPE DHT11
DHT dht(DHT_PIN, DHT_TYPE);
void setup() {
Serial.begin(115200);
dht.begin();
}
void loop() {
delay(2000);
float t = dht.readTemperature();
float h = dht.readHumidity();
if (!isnan(t) && !isnan(h)) {
}
}
genbots

