Temperature and humidty collector
Update time：2018-04-13 Views：5319
DHT22 temperature and humidity sensor
This paper describes how to use DHT22 temperature and humidity sensors on the Fireduino to achieve temperature and humidity acquisition. DHT22 is single bus digital sensors,temperature measuring range:-40℃--80℃,measuring accuracy:0.5℃.Humidity measurement range:0--100%RH,measurement accuracy:2%RH,resolution:16位.
Fireduino and DHT22 sensor connection
DHT22 can use 3.3V or 5.0V power supply,you can easily on the Arduino board 3.3V or 5.0V on the interface to take power. The hardware connection is very simple,only need to connect the DHT22 sensor and the PIN5 pin.
Prepare DHT22 sensor support library
Read the sensor has packaging good library,the download link: https://github.com/RobTillaart/Arduino/tree/master/libraries/DHTstable After download,extract the libraries directory of the arduino.
#include <dht.h> //Include the header filedht DHT; //Define the dht sensor object#define DHT22_PIN 5 //According to the connection situation of the dht sensor signal to determine //Read DHT22 sensorint chk = DHT.read22(DHT22_PIN); //Read to the sensor data,output to the serial portSerial.print(DHT.humidity, 1);Serial.print(",\t");Serial.print(DHT.temperature, 1);Serial.print(",\t");