The DFRobot DHT22 Temperature & Humidity Sensor V2 is a reliable sensor module capable of measuring both temperature and humidity with high accuracy. It utilizes the DHT22 sensor, which is known for its long-term stability and calibration. This sensor is widely used in various applications such as weather stations, home environment monitoring, HVAC systems, and any project where precise atmospheric conditions are needed.
Pin Number | Name | Description |
---|---|---|
1 | VCC | Power supply (3.3 to 6V DC) |
2 | DATA | Digital output signal |
3 | NC | Not connected |
4 | GND | Ground |
#include "DHT.h"
#define DHTPIN 2 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT22 // DHT 22 (AM2302)
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(F("Failed to read from DHT sensor!"));
return;
}
// Compute heat index in Celsius (isFahrenheit = false)
float heatIndex = dht.computeHeatIndex(temperature, humidity, false);
Serial.print(F("Humidity: "));
Serial.print(humidity);
Serial.print(F("% Temperature: "));
Serial.print(temperature);
Serial.print(F("°C Heat index: "));
Serial.print(heatIndex);
Serial.println(F("°C"));
}
Q: Can the sensor be used outdoors? A: Yes, but it should be protected from direct sunlight, rain, and condensation.
Q: How long does the sensor need to acclimate to a new environment? A: It typically takes about 30 minutes to an hour for the sensor to stabilize and provide accurate readings.
Q: Is calibration required for the sensor? A: The DHT22 sensor comes pre-calibrated from the factory. However, for critical applications, periodic calibration against a known standard may be necessary.