Description
The DHT11 sensor is one of the most popular sensors for measuring temperature and humidity, especially in Arduino projects because it is easy to use, cheap, and readily available.
What is DHT11?
DHT11 is a sensor that measures temperature and relative humidity in the air. This sensor has a capacitive humidity sensor and a thermistor temperature sensor inside, which outputs digital data, making it very easy to connect to Arduino.
DHT11 specifications
list
|
details
|
Humidity measurement range
|
20–90% RH (±5% RH)
|
Temperature measurement range
|
0–50°C (±2°C)
|
Supply voltage
|
3.3V – 5.5V
|
Output signal
|
Single-wire digital
|
Read Rate
|
1 time/second (1Hz)
|
Number of legs
|
3 legs (VCC, GND, Data) or 4 legs (if it is a module but actually uses 3 legs)
|
Using DHT11 with Arduino
Wiring:
DHT11
|
Arduino
|
VCC
|
5V
|
GND
|
GND
|
DATA
|
Digital Pin (eg. D2)
|
Some models have a pull-up resistor (about 10KΩ) already attached to the module. If it is a bare sensor, you may need to connect your own resistance.
Arduino code example:
Requires DHT library, which can be installed via Library Manager.
define DHTPIN 2 // The pin connected to the DHT11's Data #define DHTTYPE DHT11 // The type of sensor
DHT dht(DHTPIN, DHTTYPE); void setup() { Serial.begin(9600); dht.begin(); }
void loop() { float h = dht.readHumidity(); float t = dht.readTemperature();
if (isnan(h) || isnan(t)) { Serial.println("Read failed!"); return; }
Serial.print("Humidity: "); Serial.print(h); Serial.print(" %\t"); Serial.print("Temperature: "); Serial.print(t); Serial.println(" *C"); delay(2000); // wait 2 seconds }
