I’ve been struggling to get this program working. I’m using a humidity sensor to turn a fogger on and off through a relay for an aeroponics project. First, I was getting “0” as the reading because the firmware hadn’t been upgraded. I updated the firmware after numerous failed attempts. Then, I got error messages, so I reinstalled the software. Now, it freezes up when I run the program. It just sits there with a gray cursor.
Here’s the program I’m running. I’m using a RPi B+ with a GrovePi running Raspbian, the digital temp/humidity sensor, and the Grove Relay. The relay worked fine when the sensor reading was coming out “0”. And I wrote a separate program just to turn the relay off and it worked.
Here is the program:
import time
import grovepi
import sys
sensor=7
relay=4
while True:
try:
sys.stderr.write(“x1b[2Jx1b[H”)
[temp, humidity]=grovepi.dht(sensor,1)
print humidity
if humidity < 80:
grovepi.digitalWrite(relay,1)
time.sleep(5)
else:
grovepi.digitalWrite(relay,0)
except IOError:
print “Error”
I’ve rebooted the Pi multiple times. I put several print commands in and it appears to be freezing at the [temp, humidity]=grovepi.dht(sensor,1) line. It prints just before that but does not print just after that. The sensor is plugged into port D7 and the relay is plugged into D4.
i2cdetect shows a 04 in the (00,4) cell. I can post a picture if it helps. When I run the program, grove_dht_pro.py, I just get temp = nan and humidity = 0.0.
I’ve been having issues updating the firmware also. Yesterday, I got it to (appear to) work once, but it never asked me the question about I2C Search or Direct upload. It did say “Fuses OK” at the end.
Today, I’m trying to run it again and I just get,
“Cloning into ‘GrovePi’…
error: gnutls_handshake() failed: A TLS packet with unexpected length was received. while accessing https://github.com/DexterInd/GrovePi/info/refs
fatal: HTTP request failed” It kept giving me that message yesterday also. I downloaded the files directly from github and that didn’t work either. Finally, it simply worked, but maybe not completely.
Is there another way to update the firmware? When I run the program to check the firmware, it says, “GrovePi has firmware version: 1.2.2”
Any help would be appreciated. Tomorrow is the last day of school for these students and their project was featured on the instructables website. People are waiting for the updated code. Thanks!
I rebooted the Pi and then ran the firmware update again. Once again, it appears to work, but it didn’t ask me the question about Direct upload or I2C search like the instructions say. Here’s how the install went:
Updating the GrovePi firmware
Do you want to update the firmware? [y,n]y
Make sure that GrovePi is connected to Raspberry Pi
Firmware found
Connect the jumper to the Reset pin and Press any key to start firmware update
. . .
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x1e950f
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "grove_pi_firmware.hex"
avrdude: input file grove_pi_firmware.hex auto detected as Intel Hex
avrdude: writing flash (14480 bytes):
OK, it seems to be mostly working now. I used a new sensor, a new raspberry pi, I updated the firmware about 10 times, and put new wires. I don’t know which one fixed it. Two issues now. 1- The humidity isn’t coming out as a number from 0-100 like I’ve seen in the examples. It’s coming out in the range of 1500-3000. Not the end of the world.
2- The program crashes with an IOError after about 10 minutes. The error reads:
IOError
Traceback (most recent call last):
File “aero.py”, line 12, in <module>
[temp, humidity]=grovepi.dht(sensor,1)
TypeError: ‘int’ object is not iterable
I put an error-catching line in my program, but this appears to be happening in the dht module or grovepi module. Any way to keep it from crashing when this error occurs?
There is no way around the exception handling, the GrovePi is sometimes unable to read the values from the sensors and gives out an IO Error but it should be pretty easy to catch it and resolve the problem.
I’ve had the same issue on and off. There are many things that could be causing it. Make sure to update the firmware on your GrovePi if you haven’t already. The old firmware does not support dht. Also, I found that the temp/humidity sensors are not stainless steel and they corrode in the fog. That’s a pretty huge design flaw.