Hi.
I'm using a DHT22 sensor.
The temperature reading i get is close enough to correct temperature, but humidity showed is 1% at room conditions.
When i breath over the sensor the humidity keeps going up to 99% then goes back to 1%.
Is the sensor broken or there is some calibration i should do?
thank you in advance.
Hi,
What code are you using??
Example here: HERE
(You need to change example from DHT11 to DHT22)...
Hi.
I was using this code:
// DHT Temperature & Humidity Sensor
// Unified Sensor Library Example
// Written by Tony DiCola for Adafruit Industries
// Released under an MIT license.
// Depends on the following Arduino libraries:
// - Adafruit Unified Sensor Library: https://github.com/adafruit/Adafruit_Sensor
// - DHT Sensor Library: https://github.com/adafruit/DHT-sensor-library
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#define DHTPIN 2 // Pin which is connected to the DHT sensor.
// Uncomment the type of sensor in use:
//#define DHTTYPE DHT11 // DHT 11
#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
// See guide for details on sensor wiring and usage:
// https://learn.adafruit.com/dht/overview
DHT_Unified dht(DHTPIN, DHTTYPE);
uint32_t delayMS;
void setup() {
Serial.begin(9600);
// Initialize device.
dht.begin();
Serial.println("DHTxx Unified Sensor Example");
// Print temperature sensor details.
sensor_t sensor;
dht.temperature().getSensor(&sensor);
Serial.println("------------------------------------");
Serial.println("Temperature");
Serial.print ("Sensor: "); Serial.println(sensor.name);
Serial.print ("Driver Ver: "); Serial.println(sensor.version);
Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id);
Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println(" *C");
Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println(" *C");
Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println(" *C");
Serial.println("------------------------------------");
// Print humidity sensor details.
dht.humidity().getSensor(&sensor);
Serial.println("------------------------------------");
Serial.println("Humidity");
Serial.print ("Sensor: "); Serial.println(sensor.name);
Serial.print ("Driver Ver: "); Serial.println(sensor.version);
Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id);
Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println("%");
Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println("%");
Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println("%");
Serial.println("------------------------------------");
// Set delay between sensor readings based on sensor details.
delayMS = sensor.min_delay / 1000;
}
void loop() {
// Delay between measurements.
delay(delayMS);
// Get temperature event and print its value.
sensors_event_t event;
dht.temperature().getEvent(&event);
if (isnan(event.temperature)) {
Serial.println("Error reading temperature!");
}
else {
Serial.print("Temperature: ");
Serial.print(event.temperature);
Serial.println(" *C");
}
// Get humidity event and print its value.
dht.humidity().getEvent(&event);
if (isnan(event.relative_humidity)) {
Serial.println("Error reading humidity!");
}
else {
Serial.print("Humidity: ");
Serial.print(event.relative_humidity);
Serial.println("%");
}
}
With this code i get 21.4°c and 1% humidity.
With the code in the link you gave i get
Read sensor: Checksum error
Humidity (%): 0.00
Temperature (oC): 0.00
Temperature (oF): 32.00
Temperature (K): 273.15
Dew Point (oC): nan
Dew PointFast (oC): nan
but i think because i didn't modify it correctly for dht22 (don't know how exactly, the library does not include dht22).
So i put my sensor into the fridge for about 1 hour, then i immidiately connected it to the arduino (at room temperature and humidity), and watched the output on the serial monitor:
DHTxx test!
Humidity: 54.00 % Temperature: 15.00 *C 59.00 *F Heat index: 13.97 *C 57.14 *F
Humidity: 56.00 % Temperature: 15.20 *C 59.36 *F Heat index: 14.24 *C 57.63 *F
Humidity: 56.80 % Temperature: 15.30 *C 59.54 *F Heat index: 14.37 *C 57.86 *F
Humidity: 58.20 % Temperature: 15.30 *C 59.54 *F Heat index: 14.41 *C 57.93 *F
Humidity: 59.00 % Temperature: 15.40 *C 59.72 *F Heat index: 14.54 *C 58.17 *F
Humidity: 59.70 % Temperature: 15.50 *C 59.90 *F Heat index: 14.66 *C 58.40 *F
Humidity: 60.30 % Temperature: 15.60 *C 60.08 *F Heat index: 14.79 *C 58.62 *F
Humidity: 60.90 % Temperature: 15.70 *C 60.26 *F Heat index: 14.92 *C 58.85 *F
Humidity: 61.50 % Temperature: 15.80 *C 60.44 *F Heat index: 15.04 *C 59.07 *F
...
Humidity: 86.30 % Temperature: 19.10 *C 66.38 *F Heat index: 19.32 *C 66.77 *F
Humidity: 86.50 % Temperature: 19.20 *C 66.56 *F Heat index: 19.43 *C 66.98 *F
Humidity: 86.40 % Temperature: 19.20 *C 66.56 *F Heat index: 19.43 *C 66.98 *F
Humidity: 86.50 % Temperature: 19.20 *C 66.56 *F Heat index: 19.43 *C 66.98 *F
Humidity: 85.50 % Temperature: 19.20 *C 66.56 *F Heat index: 19.41 *C 66.93 *F
Humidity: 83.60 % Temperature: 19.30 *C 66.74 *F Heat index: 19.47 *C 67.04 *F
Humidity: 81.00 % Temperature: 19.30 *C 66.74 *F Heat index: 19.40 *C 66.92 *F
Humidity: 78.00 % Temperature: 19.40 *C 66.92 *F Heat index: 19.43 *C 66.98 *F
Humidity: 73.20 % Temperature: 19.40 *C 66.92 *F Heat index: 19.31 *C 66.75 *F
Humidity: 67.60 % Temperature: 19.40 *C 66.92 *F Heat index: 19.16 *C 66.49 *F
Humidity: 61.30 % Temperature: 19.50 *C 67.10 *F Heat index: 19.11 *C 66.39 *F
...
Humidity: 2.10 % Temperature: 19.80 *C 67.64 *F Heat index: 17.89 *C 64.20 *F
Humidity: 1.00 % Temperature: 19.80 *C 67.64 *F Heat index: 17.86 *C 64.15 *F
Humidity: 1.00 % Temperature: 19.80 *C 67.64 *F Heat index: 17.86 *C 64.15 *F
Humidity: 1.00 % Temperature: 19.80 *C 67.64 *F Heat index: 17.86 *C 64.15 *F
As you can see, the humidity kept rising until temperature reaches about 19°c when it suddenly falls to the usual 1%.
Any ideas? thank you.