I’m having an issue with GrovePi in python when reading from multiple digital pins in short consecutive order. I’ve adapted your sample GrovePi/Software/Python/grove_dht_pro.py to read from two DHT22 sensors instead of one to investigate the issue.
Depending on how long I wait between the read from one ot the other sensor I get the same reading from the previous port when the wait is too short. I tried that using IKPdb debugger and by manually running another script for one and then the other port right after each other. No matter what i try I have to wait between 1-2 seconds between read from D6 and D8 to get different Temperature/Humidity readings. If i do not wait between read from D6 and D8 i get the same D6 reading from D8 as well. As if GrovePi needs 2 seconds to switch between D6 and D8.
I started with a fresh Vanilla Raspbian installation. NOT the Dexter version. Grovepi was cloned from git and installed with the scripts.
The reads used to work on my old installaion in a Dexter Raspbian. But afer a update with the Dexter Sofware Update tool ALL my custom scripts and data in /var/www got deleted! So I thought that wont happen to me again so I reinstalled my RPi3s SD wih a original Raspbian.
What I did just before reinstalling Raspbian was a GrovePi Firmware Update from 1.2.2. to 1.2.7. I’m not absolutely certain but it might be that the issue started right after the update in the Dexter Raspbian already, but for sure it’s present now. I alredy tried reinstalling the 1.2.7 firmware again.
I’ve seen something in the Firmware changelog of 1.2.7 about faster IO and so on. I would have thought that this would improve my problem if anything but does not seem so.
So what elese can I do?
Here’s my sample code:
sensor = 8 # The Sensor goes on digital port 4.
sensor2 = 6 # The Sensor goes on digital port 4.
blue = 0 # The Blue colored sensor.
white = 1 # The White colored sensor.
[temp,humidity] = grovepi.dht(sensor,white)
#Here I have to wait for 1-2 seconds to get both readings correct.
[temp2,humidity2] = grovepi.dht(sensor2,white)
if math.isnan(temp) == False and math.isnan(humidity) == False:
print(“temp = %.02f C humidity =%.02f%%”%(temp, humidity))
print(“temp2 = %.02f C humidity =%.02f%%”%(temp2, humidity2))
except IOError: print ("Error")