Introduction
The DHT11 is a basic, low-cost digital temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor to measure the surrounding air and outputs a digital signal on the data pin. It's simple to use and ideal for environmental sensing and data logging and perfect for a weather station or humidor control system.
Common Applications and Use Cases
- Home environment monitoring
- Weather stations
- Automotive climate control
- Humidifiers and dehumidifiers
- Medical and health applications
Technical Specifications
Key Technical Details
- Voltage: 3.3 to 5V power and I/O
- Current: 2.5mA max current use during conversion (while requesting data)
- Humidity: 20-80% with 5% accuracy
- Temperature: 0-50°C with ±2°C accuracy
- Sampling Rate: No more than 1 Hz sampling rate (once every second)
Pin Configuration and Descriptions
Usage Instructions
How to Use the DHT11 in a Circuit
Powering the Sensor: Connect the VCC pin to a 3.3V or 5V power supply. The GND pin should be connected to the ground on your microcontroller board.
Data Connection: Connect the DATA pin to a digital I/O pin on your microcontroller.
Pull-up Resistor: A pull-up resistor (typically 4.7kΩ to 10kΩ) is required on the DATA pin to pull it up to the level of VCC.
Important Considerations and Best Practices
- The DHT11 is relatively slow and you should wait at least 1 second between readings.
- Avoid placing the sensor in direct sunlight or near a heat source to get accurate readings.
- Ensure that the sensor is not exposed to condensation or water.
Example Code for Arduino UNO
#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();
// Read temperature as Celsius (the default)
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 heat_index = dht.computeHeatIndex(temperature, humidity, false);
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.print("% Temperature: ");
Serial.print(temperature);
Serial.print("°C Heat index: ");
Serial.print(heat_index);
Serial.println("°C");
}
Troubleshooting and FAQs
Common Issues Users Might Face
- Inaccurate Readings: Ensure the sensor is not affected by heat sources or direct sunlight.
- No Data: Check the wiring, especially the pull-up resistor on the DATA pin.
- Erratic Readings: Ensure there's a stable power supply and the sampling rate is not too high.
Solutions and Tips for Troubleshooting
- Sensor Not Responding: Reset the power to the sensor and ensure the correct pin is used for data.
- Consistently High or Low Humidity Readings: Calibrate the sensor in an environment with a known humidity level.
- Long Cable Runs: Keep the cable between the sensor and microcontroller short to prevent signal degradation.
FAQs
Q: Can the DHT11 sensor measure temperature below 0°C?
A: No, the DHT11 is limited to a temperature range of 0 to 50°C.
Q: How long should I wait between readings?
A: Wait at least 2 seconds between readings to ensure accurate measurements.
Q: Can I use the DHT11 sensor with a Raspberry Pi?
A: Yes, the DHT11 can be used with a Raspberry Pi using a suitable library for interfacing.
Q: Is the DHT11 sensor waterproof?
A: No, the DHT11 is not waterproof and should be protected from moisture and condensation.