Go Down

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


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.


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?


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.println("DHT11 TEST PROGRAM ");
  Serial.print("LIBRARY VERSION: ");

void loop()

  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;
  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));



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.


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.

Go Up