Hardware need:
1. Arduino Pro Mini
2. Sensor DHT22
3. Some jumper cables
Step 1. Making circuit
The circuit is simple, when power source can take from Arduino Pro Mini, data cable can connect to any pin (let's say pin no. 7)
Step 2. Code works
In order to use DHT22 sensor, library for it need to be installed
It also need to copy file Adafruit_sensor.h into Library directory. The file can be download here (Google share link)
Note that: lack of Adafruit_Sensor.h will trigger the error:
C:\Users\xxxx\Documents\Arduino\libraries\DHT_sensor_library\DHT_U.h:25:29: fatal error: Adafruit_Sensor.h: No such file or directory
That's it. Enough lib and file, the code is compiled successful:
#include <DHT.h>; //Constants #define DHT_PIN 7 // Output of DHT22 to pin 7 Arduino #define DHT_TYPE DHT22 // DHT22 (AM2302) DHT dht(DHT_PIN, DHT_TYPE); // Initialize DHT sensor for Arduino 16MHz //Variables int chk; float hum; //Stores humidity value float temp; //Stores temperature value void setup() { Serial.begin(9600); dht.begin(); } void loop() { //Read value of Humidity and Temperature hum = dht.readHumidity(); temp= dht.readTemperature(); //Print out value of Humidity and Temperature Serial.print("Humidity is: "); Serial.print(hum); Serial.print("% --- Temp is: "); Serial.print(temp); Serial.println("dgC"); delay(2000); //Delay 2 sec. }
As checking with another temperature sensor, the temperature from DHT22 is near with the sensor. However, with humidity, we don't have test tool to test it.
ReplyDeletehello if you can put in your application and sensor application SI 7021 !!
hello, is THIS CALIBRATED DHT22 FULL FAILURE THAT IT WILL MAKE THIS PARAMETERS
ReplyDeleteevery sensor has its own parameter, and it will need standard humidity to find the parameters.
Delete