The DHT11 is a basic, low-cost digital temperature and humidity sensor manufactured by Arduino. It uses a capacitive humidity sensor and a thermistor to measure the surrounding air and outputs a digital signal on the data pin. This sensor is widely used in various applications due to its simplicity and affordability.
Parameter | Value |
---|---|
Operating Voltage | 3.3V to 5.5V |
Max Current | 2.5mA |
Humidity Range | 20-90% RH |
Temperature Range | 0-50°C |
Humidity Accuracy | ±5% RH |
Temperature Accuracy | ±2°C |
Sampling Rate | 1Hz (one reading per second) |
Signal Type | Digital |
Pin Number | Pin Name | Description |
---|---|---|
1 | VCC | Power supply (3.3V to 5.5V) |
2 | Data | Serial data output |
3 | NC | Not connected |
4 | GND | Ground |
#include "DHT.h"
#define DHTPIN 2 // Pin where the DHT11 is connected
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
delay(2000); // Wait a few seconds between measurements
float h = dht.readHumidity();
float t = dht.readTemperature();
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" *C");
}
By following this documentation, users can effectively integrate the DHT11 sensor into their projects, ensuring accurate temperature and humidity measurements.