as a newbie python programmer i want to tinker with my pi2 with a grovepi+ attached and the Grove Dust sensor. I installed the needed software for the grovepi+. Doing sudo i2cdetect -y 1 gives
(i have more sensors installed (and will install more) but want tot start with the dust sensor)
When i run grove_dust_sensor.py i get indentation errors… why and how do i solve this? I am using Python 2.7.9.
When i run grove_firmware_version_check.py i get the following:
Traceback (most recent call last):
File “/home/pi/Desktop/GrovePi/Software/Python/grove_firmware_version_check.py”, line 40, in <module>
print (“GrovePi has firmware version:”, grovepi.version())
File “build/bdist.linux-armv7l/egg/grovepi.py”, line 258, in version
return “%s.%s.%s” % (number[1], number[2], number[3])
TypeError: ‘int’ object has no attribute ‘getitem’
Hi,
Can you first check the version of the firmware on the GrovePi by running: sudo python ~/Desktop/GrovePi/Software/Python/grove_firmware_version_check.py. If you get v1.2.5, you are good. If not go to GrovePi/Firmware/Source/v1.2/grove_pi_v1_2_5 folder and run avrdude -c gpio -p m328p -U flash:w:grove_pi_v1_2_5.cpp.hex, then check the firmware version again and then try the example again.
I tried the grove firmware check but got this error again:
Traceback (most recent call last):
File “/home/pi/Desktop/GrovePi/Software/Python/grove_firmware_version_check.py”, line 40, in <module>
print (“GrovePi has firmware version:”, grovepi.version())
File “/home/pi/Desktop/GrovePi/Software/Python/grovepi.py”, line 258, in version
return “%s.%s.%s” % (number[1], number[2], number[3])
TypeError: ‘int’ object has no attribute ‘getitem’
So i tried you’re second option and did the update. That went well (safemode: Fuses and no errors).
I tried the the firmware check again and got the same result back as before.
I’m no python expert but i read the error as if grovepi.py has a python error in it’s code. I can’t imagine that such would be true. Here the results form Python 2.7.9 and
Python 2.7.9 (default, Mar 8 2015, 00:52:26)
[GCC 4.9.2] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>
Traceback (most recent call last):
File “/home/pi/Desktop/GrovePi/Software/Python/grove_firmware_version_check.py”, line 40, in <module>
print (“GrovePi has firmware version:”, grovepi.version())
File “build/bdist.linux-armv7l/egg/grovepi.py”, line 258, in version
return “%s.%s.%s” % (number[1], number[2], number[3])
TypeError: ‘int’ object has no attribute ‘getitem’
>>>
and
Python 3.4.2 (default, Oct 19 2014, 13:31:11)
[GCC 4.9.1] on linux
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>
Traceback (most recent call last):
File "/home/pi/Desktop/GrovePi/Software/Python/grove_firmware_version_check.py", line 37, in <module>
import grovepi
File "/home/pi/Desktop/GrovePi/Software/Python/grovepi.py", line 530
print data_back
^
SyntaxError: Missing parentheses in call to 'print'
>>>
I removed the grovepi+ from the pi. Then i removed two other sensors from the grovepi so that just the dust sensor remained. I then replaced the grovepi+ on the pi and started up agian.
When i now run ‘grove_firmware_version_check.py’ it says without any error: (‘GrovePi has firmware version:’, ‘1.2.5’).
So when i run grove_dust_sensor.py now, i still get a Tab/space error: Inconsistent indentation detected. When i try to change this file (Select All and untabify region) it seems the folder permissions deny me to save the file. So i saved the file elsewhere and executed.
It runs ok but the readings are not:
Reading from the dust sensor
0
0
0
0
Error
0
0
0
0
0
0
0
Are you running this example and is the dust sensor connected to port 8. Is there anything else connected to the GrovePi or the Raspberry Pi and can you run this for a couple of minutes to see if it gives you a good reading.
These readings look strange to me. As i understand, the first bit is an indicator for a new value and the rest should be the measurement. In the first few readings, the first bit is 0 but it did measure a value (the part after the comma).
Then when the first bit is an 1, the reading after the comma differs from the one in the lowpulseoccupancy printline. How come?
Are the readings above anything like a normal reading? For when i take a peek at seeeds, i see readings like 350.00 pcs per 0.01cf. Those readings look nothing like the readings i do?