0

I have rigged two different DHT22 sensors to an Arduino Nano board. Both temperature readings are more or less comparable but they produce very different humidity readings.

The sensors are:

The simple code is build on one of the basic examples as followed:

#include "DHT.h"
#define DHTPIN_2 2     // Digital pin connected to the DHT sensor_1
#define DHTPIN_3 3     // Digital pin connected to the DHT sensor_2
#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321
#define DHTTYPE_11 DHT11   // DHT 11  (AM2302), AM2321

DHT dht_1(DHTPIN_2, DHTTYPE);
DHT dht_2(DHTPIN_3, DHTTYPE);


void setup() {
  Serial.begin(9600);   //consider baud in serial monitor!
  Serial.println(F("DHT22 test!"));
  dht_1.begin();
  dht_2.begin();
}

void loop() {
  delay(5000);
  float h_1 = dht_1.readHumidity();
  float t_1 = dht_1.readTemperature();
  float h_2 = dht_2.readHumidity();
  float t_2 = dht_2.readTemperature();

  //Check if any reads failed and exit early (to try again).
  if (isnan(h_1) || isnan(t_1)) {
    Serial.println(F("Failed to read from DHT sensor_1!"));
    return;
  }

  // Check if any reads failed and exit early (to try again).
  if (isnan(h_2) || isnan(t_2)) {
    Serial.println(F("Failed to read from DHT sensor_2!"));
    return;
  }
  Serial.print(F("Humidities: "));
  Serial.print('\n');
  Serial.print(F("s_1: "));
  Serial.print(h_1);
  Serial.print(F(" s_2: "));
  Serial.print(h_2);
  Serial.print('\n');
  Serial.print(F("Temperatures: "));
  Serial.print('\n');
  Serial.print(F("s_1: "));
  Serial.print(t_1);
  Serial.print(F(" s_2: "));
  Serial.print(t_2);
  Serial.print('\n');
}

The resulting output on the Serial Monitor is:

Temperatures: 
s_1: 25.30 s_2: 23.40
Humidities: 
s_1: 6.20 s_2: 66.40
Temperatures: 
s_1: 25.20 s_2: 23.40
Humidities: 
s_1: 6.00 s_2: 66.10
Temperatures: 
s_1: 25.10 s_2: 23.40
.
.   
.

The humidity reading from sensor_1 seems defective, just having the 10th of the value of sensor_2. Is there a fix for that? Is it possible to re calibrate sensor_1 or is it broken?

Thank you!

Edit: swapping the sensors (suggested by jsotola)

The output results in:

Temperatures: 
s_1: 22.60 s_2: 24.70
Humidities: 
s_1: 67.80 s_2: 7.30

Its the sensor it seems.

4
  • swap the two sensors around
    – jsotola
    Commented Oct 13, 2023 at 16:39
  • Thanks,@jsotola, i did and posted the results.
    – nick
    Commented Oct 13, 2023 at 17:45
  • the other thing to do is to connect only one sensor at a time
    – jsotola
    Commented Oct 13, 2023 at 21:46
  • One sensor at a time delivers the same results as above (depending on which sensor is connected). The IDUINO-DHT22 still has this very low value for humidity returned.
    – nick
    Commented Oct 17, 2023 at 7:50

1 Answer 1

0

The difference in humidity readings may be traced to any number of reasons including faulty parts, incorrect programming or low voltages (please post at what voltage you are running the sensors at) to name a few.

Let us speculate that one of the sensors is reporting relative humidity and the other absolute. Absolute humidity does not consider temperature where as relative does. From this web site we get the following conversion equation:

relative to absolute humidity equation

This equation converts relative humidity to absolute. Finding the saturation vapor pressure measured in pascal is not trivial. So we will use this web site to calculate this value.

Let us use the sample:

  • Temperature 1: 22.60 C
  • Temperature 2: 24.70 C
  • (assumed) Relative Humidity: 67.80 %
  • (assumed) Absolute Humidity: 7.30

So, average temperature is 23.65 C. Using this temperature and the above web page, the vapor pressure is 2923 PA.

AH = (67.80 x 2923) / (462.5 x (273.15 + 23.65) x 100) AH = 0.014437 Kg/(meter cubed)

As absolute humidity is normally written as grams per cubic meter:

AH g/(meter cubed) = 0.014437 * 1000 = 14.43 g/(meter cubed)

14.43 is not 7.30. Consider your options. Check your circuit, voltages and software (does varying the amount of time between samples result in different values). Also consider running more tests in better conditions (placing both sensors inside the same sealed container over a long period of time to mitigate exposure to different conditions).


Added later...

Evidently problems with the DHT11 humidity sensor is a known problem:

6
  • Thank you so much @st2000 for this detailed answer and the good hints on how to proceed! What I checked: The voltage on the USB to the Nano is 5.06V with 0.023A (no difference if one or both sensors are connected). I tried an USB hub with additional power, no effect. I set the delay(10000), which doubled the time but had no effect. I put the whole setup into a plastic container. After 30 minutes of equilibration the humidity readings are keeping this difference. The temperature however is now 0.1° apart :) . You clearly ruled out that the sensor is reporting AH instead of RH.
    – nick
    Commented Oct 17, 2023 at 8:24
  • The specifications for this sensor in the link above states that it reports RH. This leaves the programming. Not sure if I am able to go into the DHT.h. I assume the problem is still with the sensor. Coming back to my initial question: is it possible to redo the calibration on that one?
    – nick
    Commented Oct 17, 2023 at 8:30
  • I meant to check the voltage provided the DHT22 sensors. Some Arduinos run at 3.3V and others at 5V. Somewhere I read the DHT22 runs better at the higher voltage. I see the Alexnd webpage says 5V and the Grove web page says 3.3 to 5V. LOL. Also, you may have a bad sensor. Do you have another to swap out with? Lastly, I've had bad luck w/DHT22 sensors too and switch to Sillicon Lab Si7021 sensors.
    – st2000
    Commented Oct 17, 2023 at 12:13
  • Oh! Something you might try. You didn't provide a schematic. But if the internet is anything to go by, about 33% of DHT22 projects posted place a 10K pull up resistor on the DHT22's data pin. This is because most serial interfaces like this one use a open collector output so that multiple devices can share a single digital wire. What about the other 77%? Well, the driver should activate an internal processor pull up resistor. But, these resistors very widely. So, try adding a 10K pull up resistor the the digital pin of the problematic DHT22 ... just to see what happens.
    – st2000
    Commented Oct 17, 2023 at 12:24
  • I added some links to some forum discussions about the DHT22 humidity sensor. There are more good suggestions in some of these if you want to go the distance. But I'd check the voltage at the sensors, I might try the pull up (but I think there's only a slim chance that will work) finally I would switch to some of the recommended sensors and buy from a well established company that has a community of uses who you can ask questions of.
    – st2000
    Commented Oct 17, 2023 at 12:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.