Go Down

Topic: DHT11 - temp ok, but RH values wildly off (Read 5588 times) previous topic - next topic

jbishop129

Hi all, I have 3x DHT11 temp / humidity sensors. (datasheet: http://www.micropik.com/PDF/dht11.pdf)
These are great, inexpensive, digital sensors, however I am having trouble with the RH value varying wildly between different sensors. For example, of the 3 sensors I have, one reads 11%, second one reads 27%, and 3rd reads 34%, all sitting right next to each other. The temp readings all match each other. For each of them, I can "blow on them" and watch the RH reading climb. The datasheet indicates the RH is accurate +/- 5%, which is fine, however my results are showing a 24 point spread! Beyond that, if I place any of the sensors in a known humidity environment, for example I have several cigar humidors that are held at a relatively precise 70% RH, the sensors never show anything near that, typically topping out at around 40%. Unfortunately, an inaccurate reading is completely useless.

I'm wondering if anyone else has experienced this before, and also by contrast if the supposedly more accurate DHT22 yields much better results. If so, I wouldn't mind spending the money for a better sensor, but I don't want to throw money at the problem either.

As far as code, I am testing with the DHT11 example library, I am running this on an ATmega328, and I have switched to several different digital pins, with consistent results.

april

I would have a good re-read of the data sheet again . It looks like a lot can go wrong

I saw that you must not send any signals to the device for 1 second to allow it to stabilise - did you delay your program?

jbishop129

Thanks for the reply. I re-read the datasheet, and I noticed about the polling intervals, and also how to re-calibrate the device. My code already has appropreate delays, however I have not tried their calibration method mentioned in the article. None of the other environmental concerns apply for me. Has anyone else fiddled around with these sensors before? Below is the example code. Perhaps there is another library out there?

Code: [Select]
//
//   FILE:  dht11_test1.pde
// PURPOSE: DHT11 library test sketch for Arduino
//

//Celsius to Fahrenheit conversion
double Fahrenheit(double celsius)
{
return 1.8 * celsius + 32;
}

//Celsius to Kelvin conversion
double Kelvin(double celsius)
{
return celsius + 273.15;
}

// dewPoint function NOAA
// reference: http://wahiduddin.net/calc/density_algorithms.htm
double dewPoint(double celsius, double humidity)
{
double A0= 373.15/(273.15 + celsius);
double SUM = -7.90298 * (A0-1);
SUM += 5.02808 * log10(A0);
SUM += -1.3816e-7 * (pow(10, (11.344*(1-1/A0)))-1) ;
SUM += 8.1328e-3 * (pow(10,(-3.49149*(A0-1)))-1) ;
SUM += log10(1013.246);
double VP = pow(10, SUM-3) * humidity;
double T = log(VP/0.61078);   // temp var
return (241.88 * T) / (17.558-T);
}

// delta max = 0.6544 wrt dewPoint()
// 5x faster than dewPoint()
// reference: http://en.wikipedia.org/wiki/Dew_point
double dewPointFast(double celsius, double humidity)
{
double a = 17.271;
double b = 237.7;
double temp = (a * celsius) / (b + celsius) + log(humidity/100);
double Td = (b * temp) / (a - temp);
return Td;
}


#include <dht11.h>

dht11 DHT11;

#define DHT11PIN 12

void setup()
{
  Serial.begin(115200);
  Serial.println("DHT11 TEST PROGRAM ");
  Serial.print("LIBRARY VERSION: ");
  Serial.println(DHT11LIB_VERSION);
  Serial.println();
}

void loop()
{
  Serial.println("\n");

  int chk = DHT11.read(DHT11PIN);

  Serial.print("Read sensor: ");
  switch (chk)
  {
    case 0: Serial.println("OK"); break;
    case -1: Serial.println("Checksum error"); break;
    case -2: Serial.println("Time out error"); break;
    default: Serial.println("Unknown error"); break;
  }
  delay(2000);
 
  Serial.print("Humidity (%): ");
  Serial.println((float)DHT11.humidity, 2);

  Serial.print("Temperature (oC): ");
  Serial.println((float)DHT11.temperature, 2);

  Serial.print("Temperature (oF): ");
  Serial.println(Fahrenheit(DHT11.temperature), 2);

  Serial.print("Temperature (K): ");
  Serial.println(Kelvin(DHT11.temperature), 2);

  Serial.print("Dew Point (oC): ");
  Serial.println(dewPoint(DHT11.temperature, DHT11.humidity));

  Serial.print("Dew PointFast (oC): ");
  Serial.println(dewPointFast(DHT11.temperature, DHT11.humidity));

  delay(2000);
}
//
// END OF FILE
//

jbishop129

Through further testing, I'm wondering how the DHT11 really detects RH. If I leave it in my cigar humidor, which is 70% RH, it reads around 35%. However, if I breathe on the sensor, it will quickly climb up to about 85%. I wonder if it needs active air circulation in order to properly detect humidity.

On that note, I will try putting a little 20mm fan inside my cigar humidor and see if that affects the readings. Will report back.

jbishop129

Even with the fan for circulation, the sensor reads about 42% RH. That is about 5% higher, but still nowhere near accurate. I've tried both Adafruit's DHT11 lib and examples, as well as the DHT lib, which is a combo for the DHT11 / 22 sensors, all with the same results. I guess I will order a DHT22 and see if I get better results. I'm just having a hard time believing that this sensor could be so far out of whack.

naladka

Looks like sensor resetting procedure helps me. I think it happens when sensor is used in extreme conditions like when breathing on it or placing straight under vapor stream or ultrasonic humidifier.

all you need to do:

Step one: Keep the DHT sensor at the condition of Temperature 50~60Celsius, humidity <10%RH for 2 hours;
Step two:K keep the DHT sensor at the condition of Temperature 20~30Celsius, humidity >70%RH for 5 hours.


In my case it wasn't hard to get that environment: first one can be achieved just placing sensor in air heater (water or electric), second- just cover sensor with something wet in room temperature. After resetting i have checked measurements and surprisingly humidity was both equal on DHT11 and expensive, calibrated hygrometer.

Willian

Hello, I tested the DHT11 sensor in extreme conditions (under rain hehehe).
After it get water on it the sensor reading freezes on 60ÂșC temperature and 75% Humidity.
I waited a few days to dry the sensor properly, put him in the sun and heater for no more than 2 hours and the Temperature reading get back to the right reading (I compare with the sensor DS18B20 which also get in the rain and doesn't get any problems in the readings). But the humidity is stuck in about 35-40%, same problem of our friend jbishop129 . =\
I will try to make this resetting routine.
Thanks for the tip!

Willian

I tried the re-calibration procedure about 5 times, but the humidity still stuck in about 35 ~ 40%, any tip why?  =)
If I breath on it, the reading goes up to 60% normaly.

mrbig

Hi!


In my case it wasn't hard to get that environment: first one can be achieved just placing sensor in air heater (water or electric), second- just cover sensor with something wet in room temperature.


Those who had success with this process, did you do this with the device powered on, or did you disconnect it before?
(Trying to guess whether the recalibration is an active, or a passive process)

naladka

Power was off while recalibrating. After few days of running in normal conditions (i even didn`t breath on it), it resumes to show abnormal humidity. I was running room humidifier until real humidity rises to 55%, while DHT11 sensor still shows 14%. Maybe you can use sensor to read changes in humidity, but not the actual value. I my case i didn`t find it usefull at all.

vimtut0r

I know I'm digging out an old thread.

But I'm experiencing the same problems.

I'll try the recalibration method and report my results.

midel

#11
Feb 19, 2015, 11:37 am Last Edit: Feb 19, 2015, 11:42 am by midel
Hi,

I, too, face exactly the same problem. I wanted my Arduino + DHT11 + LCD to monitor the temp/humidity of my cigar humidor. I have an "analogical" hygrometer inside of it, and have calibrated it many times. It does work. There should be around 70-72% relative humidity inside the box. But the DHT11 keeps saying 50%.

vimtut0r, did you manage to have correct results ?

jqdoumen

midel ... I get a 20% too low reading as well (DHT22). I had about 30% inside the house, which I found hard to believe ... sensor is now in a sealed container with water, and it doesn't go higher than 80%. Would like to find out how to calibrate - that is telling the sensor his current reading is 100% - found beautiful articles on measuring accuracy, but nothing on calibration thus far ... :-(

midel

#13
Feb 22, 2015, 03:13 pm Last Edit: Feb 22, 2015, 03:20 pm by midel
Thanks jqdoumen,

So, it seems we all face the same problem... It is said that DHTxx are calibrated in the factory... But... I'm not convinced :) Anyway, measuring humidity is tricky, we should try to understand how the DHT11 humidity sensor works.

I made 2 tests :

DHT11 in a small closed container with a mix of salt and water. With not to much water, the purpose is to make a sort of salt paste. In this config, the humidity should reach 75%. It's a well known test to calibrate cigar humidor hygrometers. DHT11 humidity slowly reached 69%. Not so far.

Today i put the DHT in the same container but with only water, to aim 100%. I managed to reach 95% ! So it seems to be not so stupid !

I'll try to put the DHT11 back in the cigar humidor, to see if now i get a correct measure around 65/70% and if it stays this way several days/weeks or if it goes back to the abnormal 50% first measure.

oh, and jqdoumen, one way to cheat if you really think you have a constant 20 difference between reality and what the DHT outputs would be to add 20 to the sent value (serial or LCD). Something like :

  Serial.println((float)DHT11.humidity+20, 2);

But it's really really ugly not rigorous cheating and maybe you'll always wonder whether it is really correct or not.

jqdoumen

midel,

unfortunately the sensor does not seem to be off linearly, so adding an arbitrary number might yield strange results. My test with the saturated sodium chloride solution is still running, but it looks like it is not getting any higher then 62 (after 5 hours). So, at 100% it is 20 off, at 75% it is 13 off. I'll check if I can get easy access to magnesium chloride, to have a reference at the low end as well, and then check how ugly adding numbers actually is. I don't mind being 5% off, but 20% is a little too much.

Greetings,

ps: what resistor do you have between your pin and ground?

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy