شحن مجاني للأوردرات فوق
1000 ج
رمضان كريم
DHT22 Digital Temperature & Humidity Sensor
High-Precision Environmental Sensing for Arduino Projects
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
±0.5°C temperature, ±2% humidity
Single-wire digital communication
Up to 20m signal transmission
2-second sampling rate
| 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 | Function | Arduino Connection |
|---|---|---|
| 1 | VCC (3.3V-5V) | 5V |
| 2 | DATA | Digital Pin (D2) |
| 3 | NC | Not Connected |
| 4 | GND | GND |

// Basic Connections: // VCC → 5V // DATA → D2 (with pull-up resistor) // GND → GND
Important: Avoid long wires (>20cm) without proper shielding to prevent signal issues
#include <DHT.h> #include <Adafruit_Sensor.h>
#define DHTPIN 2 // Digital pin connected
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE);
void setup() {
dht.begin();
}
#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");
}
// Calculate heat index (feels-like temp)
float hic = dht.computeHeatIndex(t, h, false);
Serial.print("Heat index: ");
Serial.print(hic);
Serial.println("°C");
// Read temperature in Fahrenheit
float f = dht.readTemperature(true);
Serial.print("Temperature: ");
Serial.print(f);
Serial.println("°F");
// Check sensor status
if (dht.read() == DHTLIB_OK) {
Serial.println("Sensor working properly");
} else {
Serial.println("Sensor error detected");
}
// Put sensor to sleep between readings
digitalWrite(DHTPIN, LOW);
delay(60000); // Sleep for 1 minute
digitalWrite(DHTPIN, HIGH);
delay(2000); // Allow sensor to stabilize
No account yet?
Create an Account
Recent Comments