Hi
Briefly, I found out GrovePi and I though it could be a great way to fast prototyping or realize small appliances.
So I bought one and hooked up few sensors and try a ready made example.
I used a Raspberry Pi B+ and the image for Dexter, following the installation procedure, including updating the OS and the firmware.
I had already around few sensors from Groove (for MSP430) and so I choose to use the plant monitor project as test.
I did hook up the sensors, I don’t have the camera so I commented out the call to the function and tried it.
It worked nicely.
So, why I’m writing ?
I left the code running for a while and I saw after a while (15 minutes approx) the program did crash.
I took a look at the code and I saw already was using to catch the exception.
Then I decided to modify the code little bit trying to catch every specific operation error, and again after a while the code crashed instead to have the exception catch working.
#Read the data from the sensors
def read_sensor():
try:
moisture=grovepi.analogRead(mositure_sensor)
except IOError as TypeError:
print("Moisture error reading\n")
return [-1,-1,-1,-1]
try:
light=grovepi.analogRead(light_sensor)
except IOError as TypeError:
print("Light error reading\n")
return [-1,-1,-1,-1]
try:
[temp,humidity] = grovepi.dht(temp_humidity_sensor,white)
except IOError as TypeError:
print("Temp/Humidity error reading\n")
return [-1,-1,-1,-1]
if math.isnan(temp) or math.isnan(humidity): #temp/humidity sensor sometimes gives nan
return [-1,-1,-1,-1]
return [moisture,light,temp,humidity]
With the code modified as above, I noticed that the catch is not working for the temp/humidity reading.
Traceback (most recent call last):
File “./fhelper.py”, line 117, in
[moisture,light,temp,humidity]=read_sensor()
File “./fhelper.py”, line 89, in read_sensor
[temp,humidity] = grovepi.dht(temp_humidity_sensor,white)
TypeError: ‘int’ object is not iterable
Sometime the catch did work, sometime not.
I wonder if anybody else experienced this kind of problems with Python on the Raspberry using GrovePi.
So far I see that the light sensor sometime has a bad reading but so far the catch works.
The temperature is the one that failed to be catch sometime.
The errors seems quite random so far, the code it can run for hours or few minutes before to stop for the error.
Any suggestion to solve this problem ?
Thanks
Steve