DHT22 Digital Temperature & Humidity Sensor Module

DHT22 Digital Temperature & Humidity Sensor
High-Precision Environmental Sensing for Arduino Projects
Introduction
The DHT22 (AM2302) is a calibrated digital sensor that provides high-accuracy temperature and humidity measurements. With its single-wire serial interface, it’s perfect for weather stations, greenhouse monitoring, and HVAC systems.
DHT22 Digital Temperature & Humidity Sensor
Key Features
High Accuracy
±0.5°C temperature, ±2% humidity
Simple Interface
Single-wire digital communication
Long Range
Up to 20m signal transmission
Fast Updates
2-second sampling rate
Technical Specifications
Temperature Range | -40°C to 80°C |
---|---|
Humidity Range | 0-100% RH |
Operating Voltage | 3.3V – 5.5V DC |
Current Consumption | 1.5mA (measuring), 50μA (standby) |
Resolution | 0.1°C / 0.1% RH |
Dimensions | 27mm × 59mm × 13.5mm |
Pin Configuration
Pin | Function | Arduino Connection |
---|---|---|
1 | VCC (3.3V-5V) | 5V |
2 | DATA | Digital Pin (D2) |
3 | NC | Not Connected |
4 | GND | GND |
Note: Requires 4.7KΩ-10KΩ pull-up resistor between DATA and VCC
Wiring with Arduino
// Basic Connections: // VCC → 5V // DATA → D2 (with pull-up resistor) // GND → GND
Important: Avoid long wires (>20cm) without proper shielding to prevent signal issues
Library Setup
- Install the DHT sensor library by Adafruit
- Include the required libraries:
#include <DHT.h> #include <Adafruit_Sensor.h>
- Initialize the sensor:
#define DHTPIN 2 // Digital pin connected #define DHTTYPE DHT22 // DHT 22 (AM2302) DHT dht(DHTPIN, DHTTYPE); void setup() { dht.begin(); }
Basic Sensor Example
#include <DHT.h> #define DHTPIN 2 #define DHTTYPE DHT22 DHT dht(DHTPIN, DHTTYPE); void setup() { Serial.begin(9600); dht.begin(); } void loop() { delay(2000); // Wait between measurements float h = dht.readHumidity(); float t = dht.readTemperature(); if (isnan(h) || isnan(t)) { Serial.println("Failed to read from DHT sensor!"); return; } Serial.print("Humidity: "); Serial.print(h); Serial.print("%\tTemperature: "); Serial.print(t); Serial.println("°C"); }
Advanced Features
Heat Index Calculation
// Calculate heat index (feels-like temp)
float hic = dht.computeHeatIndex(t, h, false);
Serial.print("Heat index: ");
Serial.print(hic);
Serial.println("°C");
Fahrenheit Conversion
// Read temperature in Fahrenheit
float f = dht.readTemperature(true);
Serial.print("Temperature: ");
Serial.print(f);
Serial.println("°F");
Sensor Diagnostics
// Check sensor status
if (dht.read() == DHTLIB_OK) {
Serial.println("Sensor working properly");
} else {
Serial.println("Sensor error detected");
}
Power Saving
// Put sensor to sleep between readings
digitalWrite(DHTPIN, LOW);
delay(60000); // Sleep for 1 minute
digitalWrite(DHTPIN, HIGH);
delay(2000); // Allow sensor to stabilize
Troubleshooting
No Readings (NaN values)
- Verify wiring connections
- Check pull-up resistor is installed
- Ensure proper power supply (3.3V-5V)
Incorrect Values
- Keep sensor away from heat sources
- Allow 2 seconds between readings
- Check for condensation on sensor
Communication Errors
- Shorten data wire length
- Try different digital pin
- Add 100nF capacitor between VCC and GND
Related Posts
MG90S Mini Digital 180° Servo
MG90S Mini Digital 180° Servo
Metal Gear, 2.2kg·cm Torque for RC and Robotics
Introduction
The MG90S is a compact di...
XKC-Y25-V Non-Contact Water Liquid Level Sensor
XKC-Y25-V Non-Contact Water Liquid Level Sensor
Capacitive Detection Without Physical Contact
Introduction
The XKC-Y...
Waterproof Ultrasonic Obstacle Sensor, Sensor with Separate Probe
+
Waterproof Ultrasonic Obstacle Sensor
Distance Measurement with Separate Waterproof Probe
Introduction
The Wa...
Water Level Depth Detection Sensor
Water Level Depth Detection Sensor
Liquid Measurement for Arduino and IoT Projects
Introduction
The Water Level Dept...
VL53L0X Purple Laser Distance Sensor Module
VL53L0X Laser Distance Sensor Module
High-Speed, High-Precision Time-of-Flight Distance Measurement
Introduction
The...
TCS34725 RGB Color Sensor Module
TCS34725 RGB Color Sensor Module
High-Accuracy Digital Color Detection with IR Filter
Introduction
The TCS34725 is a...
TCS3200 Color Sensor Module
TCS3200 Color Sensor Module
Precise RGB Color Detection for Arduino and Embedded Projects
Introduction
The TCS3200 C...
PN532 NFC RFID Read/Write Module V3 Kit
PN532 NFC RFID Read/Write Module V3 Kit
Advanced Near Field Communication for Arduino and Embedded Systems
Introducti...
HC-SR501 PIR Motion Sensor Module
HC-SR501 PIR Motion Sensor Module
Passive Infrared Detection for Security and Automation Projects
Introduction
The H...
Flex Sensor 5.6 cm (Detect Bending Motion)
Flex Sensor 5.6cm
Bend Detection Sensor for Arduino and Wearable Electronics Projects
Introduction
The 5.6cm...
ACS712 Current Sensor Module
ACS712 5A Current Sensor Module
Hall-Effect Based AC/DC Current Measurement for Arduino Projects
Introduction
The AC...
AS608 Optical Fingerprint Sensor Module
AS608 Optical Fingerprint Sensor Module
High-Precision Biometric Recognition for Arduino and Microcontroller Projects
...
Recent Comments