DHT22 reading humidity as 2201% and temperature as 716*C

Hello everyone,

I am currently working on a hydroponics automation project for my college assignment. I have been testing my DHT22 interfaced with Arduino Mega 2560 for a few days, trying to troubleshoot a problem with its readings.

The readings are wildly off and the humidity reads as 2201% and temperature as 761*C. I have tried several libraries including the Adafruit's library, nethoncho's library, the one provided by cactus.io. Yet it still showed the same values. The connections are correct, I am even using a pull up resistor of 10K. The data pin is connected to Pin 12 of Arduino Mega.

Is it that my sensor is faulty or it has to do with my polling intervals? I am using the standard delay of 2 seconds, as suggested by the data sheet. I've looked through several related forum posts for this, but I did not come across such an issue yet.

Here's my code:

// Example sketch for DHT22 humidity - temperature sensor
// Written by cactus.io, with thanks to Adafruit for bits of their library. public domain

#include "cactus_io_DHT22.h"

#define DHT22_PIN 12     // what pin on the arduino is the DHT22 data line connected to

// For details on how to hookup the DHT22 sensor to the Arduino then checkout this page
// http://cactus.io/hookups/sensors/temperature-humidity/dht22/hookup-arduino-to-dht22-temp-humidity-sensor

// Initialize DHT sensor for normal 16mhz Arduino. 
DHT22 dht(DHT22_PIN);
// Note: If you are using a board with a faster processor than 16MHz then you need
// to declare an instance of the DHT22 using 
// DHT22 dht(DHT22_DATA_PIN, 30);
// The additional parameter, in this case here is 30 is used to increase the number of
// cycles transitioning between bits on the data and clock lines. For the
// Arduino boards that run at 84MHz the value of 30 should be about right.

void setup() {
  Serial.begin(9600); 
  Serial.println("DHT22 Humidity - Temperature Sensor");
  Serial.println("RH\t\tTemp (C)\tTemp (F)\tHeat Index (C)\t Heat Index (F)");
 
  dht.begin();
}

void loop() {
  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  dht.readHumidity();
  dht.readTemperature();
  
  // Check if any reads failed and exit early (to try again).
  if (isnan(dht.humidity) || isnan(dht.temperature_C)) {
    Serial.println("DHT sensor read failure!");
    return;
  }
 
  Serial.print(dht.humidity); Serial.print(" %\t\t");
  Serial.print(dht.temperature_C); Serial.print(" *C\t");
  Serial.print(dht.temperature_F); Serial.print(" *F\t");
  Serial.print(dht.computeHeatIndex_C()); Serial.print(" *C\t");
  Serial.print(dht.computeHeatIndex_F()); Serial.println(" *F");
  
  // Wait a few seconds between measurements. The DHT22 should not be read at a higher frequency of
  // about once every 2 seconds. So we add a 3 second delay to cover this.
  delay(2500);
}

This is the output I am getting at the serial monitor:

Most likely the error is somewhere in the "cactus_io_DHT22.h" library.

Try your sensor with the unmodified Adafruit library and the included example; if you still get weird results I'd wager your sensor is broken. If that gives the correct results, the problem is in the library you use.

Nanciro:
The readings are wildly off and the humidity reads as 2201% and temperature as 761*C.

Is there a chance the room is 76 degrees with 22 percent humidity?

bigred1212:
Is there a chance the room is 76 degrees with 22 percent humidity?

Good one. The sensor returns the values in deg C and humidity *10, the standard Adafruit library returns the corrected value (so sensor reading *= 0.1). That would explain the F value being 10x off, but not the humidity being 100x off.

But without seeing their custom library code, it's guesswork.

bigred1212:
Is there a chance the room is 76 degrees with 22 percent humidity?

That would be a pretty hot room at 76.1 degrees Celsius. 20 degrees is about room temperature.

aarg:
That would be a pretty hot room at 76.1 degrees Celsius. 20 degrees is about room temperature.

76.1 F would be 24.5 C which is a cool room temperature for my climate (27-30 C is common for my living room). Didn't look at the screen shot too closely - thought they'd be talking about F, sounded fairly reasonable for F.
So that could point to a double conversion of C to F.
Anyway, we have to wait for OP to come back with comments.

I tried changing the library yesterday and even considered the things you all mentioned above, about the room temperature. I finally came to the conclusion that my sensor must be broken and decided to order another one. But while scrolling through the sensors, I found out that the store I bought my DHT22 from labelled it wrong :frowning:

It turns out that it was a DHT11 module labelled as DHT22. Due to my lack of knowledge, I did not realize the difference between these two modules >_< Finally, I changed my code to a DHT11 code and now it's working perfectly!

Thank you, everyone, for all the suggestions, sorry for the trouble! On the brighter side, I won't have to buy a new module :smiley:

Go complain at your shop as the DHT22 is the better of the two in both accuracy and range. The DHT11 is also quite a bit cheaper than the DHT22.

Nanciro:
But while scrolling through the sensors, I found out that the store I bought my DHT22 from labelled it wrong :frowning:

It turns out that it was a DHT11 module labelled as DHT22.

Due to my lack of knowledge, I did not realize the difference between these two modules >_< Finally, I changed my code to a DHT11 code and now it's...

I hope they give you a refund/credit, but the right/honorable thing to do would be to shop you a real 22 (white) at their cost.
Just sayin"