Introduction
DHT22 capacitive humidity sensing digital temperature and humidity module is one that contains the compound has been calibrated digital signal output of the temperature and humidity sensors. Application of a dedicated digital modules collection technology and the temperature and humidity sensing technology, to ensure that the product has high reliability and excellent long-term stability.
The sensor includes a capacitive sensor wet components and a high-precision temperature measurement devices, and connected with a high-performance 8-bit microcontroller. The product has excellent quality, fast response, strong anti-jamming capability, and high cost.
Standard single-bus interface, system integration quick and easy. Small size, low power consumption, signal transmission distance up to 20 meters, making it the best choice of all kinds of applications and even the most demanding applications.
DHT22 has higher precision and can replace the expensive imported SHT10 temperature and humidity sensor.
It can measure the environment temperature and humidity to meet the high demand.The product has high reliability and good stability.If it's used and combined with special sensor Arduino expansion board,it will be easily implemented the interactive effect which related to the temperature and humidity perception.
Caution: DHT22 digital temperature and humidity sensor is designed for analog sensor interfaces.The analog port will be used as the digital which will not occupy the original digital port of the Arduino.The lines of the sensor which can transform the analog function to digital that can be use on digital port.
NOTE: The line of the DHT22 sensor module is analog--digital
Specifications
- Supply voltage: 5V
- Output voltage: 0-3.3V
- Temperature range:-40-80℃ resolution0.1℃ error <±0.5℃
- Humidity range:0-100%RH resolution0.1%RH error±2%RH
- size: 38 x 20mm
Tutorial
Connection
Sample code
Please download the Library of DHT22 at first.This program is used to test the temperature and humidity of the DHT22
#include <dht.h>
dht DHT;
#define DHT22_PIN 7
void setup()
{
Serial.begin(115200);
Serial.println("DHT TEST PROGRAM ");
Serial.print("LIBRARY VERSION: ");
Serial.println(DHT_LIB_VERSION);
Serial.println();
Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)");
}
void loop()
{
Serial.print("DHT22, \t");
int chk = DHT.read22(DHT22_PIN); //读取数据
switch (chk)
{
case DHTLIB_OK:
Serial.print("OK,\t");
break;
case DHTLIB_ERROR_CHECKSUM:
Serial.print("Checksum error,\t");
break;
case DHTLIB_ERROR_TIMEOUT:
Serial.print("Time out error,\t");
break;
default:
Serial.print("Unknown error,\t");
break;
}
Serial.print(DHT.humidity, 1);
Serial.print(",\t");
Serial.println(DHT.temperature, 1);
delay(1000);
}