[SOLVED] Grove Pi+ 'int' object has no attribute error when analogRead

Using the GrovePi+ on a Raspberry PI 3, with the latest build of Stretch Raspbian
I installed the Dexter drivers using sudo curl -kL dexterindustries.com/update_grovepi | bash from the guide. It installed without errors. I rebooted.

I did use the raspi-config menu to enable i2C. I turned off everything else in that menu except SSH.

The python script to blink an LED works fine. When using analogRead(pin) I get the following:

Traceback (most recent call last):
  File "grove_temperature_sensor.py", line 57, in <module>
    temp = grovepi.temp(sensor,'1.1')
  File "/home/pi/Dexter/GrovePi/Software/Python/grovepi.py", line 245, in temp
    a = analogRead(pin)
  File "/home/pi/Dexter/GrovePi/Software/Python/grovepi.py", line 227, in analogRead
    return number[1] * 256 + number[2]
TypeError: 'int' object has no attribute '__getitem__'

i2C matrix thing:
sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- 04 -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

I attempted to reinstallt he script. Same issue. My hardware configuration appears correct - the pins seated well from pi to GrovePi+. I bought the official grove case to protect it.

I am using this whole set up as part of the GE Predix Machine Edge tutorial: https://www.predix.io/resources/tutorials/journey.html#1750

Predix does seem to read to the Grove sensors, but it sends zeroes for all the values. I need to eliminate that this is a GrovePi/Hardware issue before troubleshooting on the Predix side. However, the fact that I can’t call the Grove sample Python scripts is a smoking gun that there’s an issue communicating to the sensors, or something.

If I’m missing critical info to solve, please let me know, but I’ve Googled extensively, and now am requesting help.

Thank you so much!

Hi @3leftturns,

I think you don’t have the latest firmware on your GrovePi.

Consequently, I would burn the firmware on the GrovePi, so please, follow these instructions:

cd /home/pi/Dexter/GrovePi/Firmware
bash firmware_update.sh # follow the instructions in here

Running the firmware_update.sh command should give you the following console output:


Updating the GrovePi firmware
=============================
 http://www.dexterindustries.com/grovepi
 Run this program:
 sudo ./firmware_update.sh

=============================
Do you want to update the firmware? [y,n]y
Make sure that GrovePi is connected to Raspberry Pi
Firmware found
Press any key to start firmware update
. . .

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f
avrdude: reading input file "0xFF"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xFF:
avrdude: load data lfuse data from input file 0xFF:
avrdude: input file 0xFF contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.


avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f
avrdude: reading input file "0xDA"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xDA:
avrdude: load data hfuse data from input file 0xDA:
avrdude: input file 0xDA contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.


avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f
avrdude: reading input file "0x05"
avrdude: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0x05:
avrdude: load data efuse data from input file 0x05:
avrdude: input file 0x05 contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of efuse verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.


avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

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 (13816 bytes):

Writing | ################################################## | 100% 7.21s

avrdude: 13816 bytes of flash written
avrdude: verifying flash memory against grove_pi_firmware.hex:
avrdude: load data flash data from input file grove_pi_firmware.hex:
avrdude: input file grove_pi_firmware.hex auto detected as Intel Hex
avrdude: input file grove_pi_firmware.hex contains 13816 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 6.63s

avrdude: verifying ...
avrdude: 13816 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

Please let us know if this solves your issue or not.

Thank you!

That did work. Thank you.