

The DHT 22 is a digital temperature and humidity sensor that provides accurate readings of temperature in Celsius and humidity in percentage. It is widely used in applications requiring environmental monitoring, such as weather stations, HVAC systems, greenhouses, and IoT projects. The sensor is known for its reliability, ease of use, and ability to provide precise measurements with minimal power consumption.








The DHT 22 sensor has the following key technical specifications:
| Parameter | Value |
|---|---|
| Operating Voltage | 3.3V to 6V |
| Operating Current | 0.3mA (measuring), 60µA (standby) |
| Temperature Range | -40°C to +80°C |
| Temperature Accuracy | ±0.5°C |
| Humidity Range | 0% to 100% RH |
| Humidity Accuracy | ±2% RH |
| Sampling Rate | 0.5 Hz (1 reading every 2 seconds) |
| Communication Protocol | Single-wire digital signal |
| Dimensions | 15.1mm x 25mm x 7.7mm |
The DHT 22 has four pins, as described in the table below:
| Pin Number | Name | Description |
|---|---|---|
| 1 | VCC | Power supply pin (3.3V to 6V) |
| 2 | DATA | Digital data output pin |
| 3 | NC | Not connected (leave unconnected) |
| 4 | GND | Ground pin |
Note: A pull-up resistor (typically 10kΩ) is required between the DATA pin and VCC for proper communication.
Below is an example Arduino sketch to read data from the DHT 22 sensor:
#include "DHT.h"
// Define the pin where the DHT 22 is connected
#define DHTPIN 2 // Connect DATA pin to digital pin 2
// Define the type of DHT sensor
#define DHTTYPE DHT22 // DHT 22 (AM2302)
// Initialize the DHT sensor
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600); // Start serial communication at 9600 baud
Serial.println("DHT 22 Sensor Test");
dht.begin(); // Initialize the DHT sensor
}
void loop() {
delay(2000); // Wait 2 seconds between readings
// Read temperature in Celsius
float temperature = dht.readTemperature();
// Read humidity in percentage
float humidity = dht.readHumidity();
// Check if the readings are valid
if (isnan(temperature) || isnan(humidity)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// Print the readings to the Serial Monitor
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.println(" %");
}
No Data or Incorrect Readings:
"Failed to Read from DHT Sensor" Error:
DHT22) is defined in the code.Slow Response Time:
Q: Can I use the DHT 22 with a 3.3V microcontroller?
A: Yes, the DHT 22 operates within a voltage range of 3.3V to 6V, making it compatible with 3.3V microcontrollers like the ESP8266 or ESP32.
Q: What is the maximum cable length for the DHT 22?
A: The recommended maximum cable length is 20 meters. However, for longer distances, use a lower pull-up resistor value (e.g., 4.7kΩ) to maintain signal integrity.
Q: How does the DHT 22 compare to the DHT 11?
A: The DHT 22 is more accurate and has a wider range for both temperature and humidity measurements compared to the DHT 11. However, it is slightly more expensive.
Q: Can I use multiple DHT 22 sensors in the same project?
A: Yes, you can use multiple sensors by connecting each DATA pin to a separate digital pin on the microcontroller.
By following this documentation, you can effectively integrate the DHT 22 sensor into your projects for reliable temperature and humidity monitoring.