Am using scratchpy with GrovePi and am getting the temperature from sensor on A0. Have the following python program but it doesn’t continuously run - see the error message below. I do not yet have firmware 1.1 but wish to know if there are known issues with the original firmware in this area and I should upgrade. I don’t like upgrading for no reason. It does not always crash at the same time (known this since counter i is not always the same value).
import scratch
import smbus
import time
import grovepi
s=scratch.Scratch()
bus=smbus.SMBus(0)
address=0x04
i=0
f=0
while True:
i=i+1
if i> 255:
i=0
f=grovepi.temp(0)
# print grovepi.analogRead(0)
time.sleep(.5)
s.sensorupdate({'temp' : f})
print i,grovepi.temp(0)
===============
CTraceback (most recent call last):
File “temp.py”, line 33, in <module>
f=grovepi.temp(0)
File “/home/pi/sensorlab/grove_scratch/grovepi.py”, line 100, in temp
a=analogRead(pin)
File “/home/pi/sensorlab/grove_scratch/grovepi.py”, line 88, in analogRead
time.sleep(.1)
KeyboardInterrupt
Hi,
There should be no issue with the AnalogRead in the old firmware. Can you tell us a bit more in detail about the issue that you are facing, along with the error that comes and the analog value that you are getting in the program.
Have changed the code slightly since the above but the error is the same - see below. Is there some tracing option I can turn on for GrovePi or is this dependent on tracing available in Python ?
Confirm I do have Firmware 1.1 since when ran GrovePi /Firmware/new_fw_search.sh this returned “You have the latest firmware”
Error I get :
Traceback (most recent call last):
File “temp.py”, line 35, in <module>
f=grovepi.temp(0)
File “/home/pi/sensorlab/grove_scratch/grovepi.py”, line 100, in temp
a=analogRead(pin)
File “/home/pi/sensorlab/grove_scratch/grovepi.py”, line 87, in analogRead
bus.write_i2c_block_data(address,1,aRead_cmd+[pin,0,0])
IOError: [Errno 5] Input/output error
Now only have read A0 and temperature sensor on A0 - still same issue - its not reliable and crashes after a few seconds and sometimes a few minutes - can’t use this in a classroom environment - will try a different sensor on A0 and see what happens.
Traceback (most recent call last):
File "temp.py", line 33, in <module>
f=grovepi.temp(0)
File "/home/pi/sensorlab/grove_scratch/grovepi.py", line 100, in temp
a=analogRead(pin)
File "/home/pi/sensorlab/grove_scratch/grovepi.py", line 90, in analogRead
number = bus.read_i2c_block_data(address,1)
IOError: [Errno 5] Input/output error