Professional Documents
Culture Documents
The DHT22 sensor is a low-cost temperature and humidity sensor. This sensor utilizes a
thermistor to measure the surrounding air, and sends out a digital signal on a data pin, which
means that no analog input pins are needed. It is a very simple sensor to utilize, however; it does
require a set timing to obtain data. This sensor is only capable of obtaining data once every two
seconds.
3 to 5V power
2.5mA mas current use during conversion
Good for 0-100% humidity readings with 2%-5% accuracy
-40 to 80 C temperature
0.5 Hz sampling accuracy
27mm X 59mm x 13.5mm (1.05 X 2.32 X0.53)
4 pins, 0.1 spacing
Connecting to Arduino
void setup() {
Serial.begin(9600);
Serial.println("DHTxx test!");
dht.begin();
}
void loop() {
delay(2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.print(" *C ");
Serial.print(f);
Serial.print(" *F\t");
Serial.print("Heat index: ");
Serial.print(hic);
Serial.print(" *C ");
Serial.print(hif);
Serial.println(" *F");
}
Libraries
This sensor will require a DHT library to work. The library can be obtained at this link
https://github.com/adafruit/DHT-sensor-library
1- Once the GitHub pages has opened click on clone or download and download as ZIP
2- After downloading the library, click on the ZIP file.
3- Once you have clicked on the ZIP file a new folder for this library will be created.
4- Erase the ZIP file and rename the library folder to DHT sensor.
Click on sketch
Include library
Name of downloaded library
Program Overview
Here a wait is being created for the sensor to take measurements. As mentioned before the
DHT22 sensor takes about 250 milliseconds and the readings may only last up to 2 seconds.