Read Multiple DHT22 Issue

I plugged grove DHT22 to the socket D7 & D8 of grovepi, then I made python code based on example like

[temp1, hum1] = grovepi.dht(7,1);
print (“1 temp=”, temp1, “thum=”, hum1)
time.sleep(1)
[temp2, hum2] = grovepi.dht(8,1);
print (“2 temp=”, temp2, “thum=”, hum2)
time.sleep(.5)

After got sensor values, it obtained was the opposite.
For example, when I test humidity of D8 sensor, the high humidity was printed in hum1.

I don’t know what’s happen.
I would appreciate it if you could help, thanks.

Hi @jason.auo,

We had a similar issue before and one of our forum users found a round about to have it working. So they found that with time, values start appearing on the right port and they become consistent, so to avoid this problem, they ignored the values which were “Nan”. You can refer to the discussion here also you can use a code like the one below and let us know if that helps.

#!/usr/bin/env python
#
import grovepi
import math
import time

white = 1   # The White colored sensor.

while True:
    for i in range(7,9):
        [temp,humidity] = grovepi.dht(i,white)
        time.sleep(1)
        [temp,humidity] = grovepi.dht(i,white)
        if math.isnan(temp) == False and math.isnan(humidity) == False:
            print("Port#%d : temp = %.02f C humidity =%.02f%%"%(i, temp, humidity))
        else:
            print("Port#%d - Fail"%(i))
        time.sleep(2)
    print("---")

-Shoban

hi, Shoban,

It’s help. Thanks for your great support,

Is this a firmware issue? And when this issue will fix?

Hi jason.auo,

Glad that it helps. It is mostly a firmware issue. We have it on our list to get it solved soon but no exact time estimates on that.

-Shoban

1 Like