[SOLVED] UV Sensor on GrovePi - "int object has no attribute getitem"

I’m using the grove uv sensor in A1. This is all a fresh image and updated firmware on GrovePi. Has anyone else gotten this error?

line 288, in getUV
uv_sensor_value = grovepi.analogRead(uv_sensor_pin) # read value of the sensor pin
File “build/bdist.linux-armv7l/egg/grovepi.py”, line 226, in analogRead
return number[1] * 256 + number[2]
TypeError: ‘int’ object has no attribute ‘getitem

The no attribute getitem error is quite common. It can be caused by many things. First I’d recommend starting with running the troubleshooter. On your desktop there should be an icon that looks like a construction hat on the Dexter Ind logo, or something like that. Open it up and select grovepi and click troubleshoot. Also do other sensors work?

Hi @paul.reisinger,

First of all, I want to thank again for @graykevinb’s support.


Getting back to our issue, you could also follow Step 3 of the following post:
forum.dexterindustries.com/t/solved-dht-sensor-responding-1/2815/2

After you’ve done getting through the throubleshooter, please post here the generated log.txt file.
Also, can you please tell us whether you’re using Raspbian For Robots or is it just a fresh Jessie image?


Thank you!

Raspbian For Robots from Dexter site.

log.txt (6.2 KB)

Hi @paul.reisinger,

Looking over the log.txt file you’ve posted, I can see the GrovePi is found at address 0x08.
It should have been found at address 0x04.

Have you been bringing any modifications to the firmware?


Provided you have the latest Raspbian For Robots on your Raspberry Pi, please follow these suggestions.

It’s going to help us a lot by providing screenshots with what the console outputs.

cd Desktop/GrovePi/Script
sudo bash install.sh
sudo reboot

After you reboot, please enter the following commands in the terminal:

cd ~/Desktop/GrovePi/Firmware
sudo bash firmware_update.sh

Again we would like to see a screenshot for these last 2 commands too.


Last but not least, do you have anything else plugged into your GrovePi?
Any sensors / devices that work with the I2C protocol?


Thank you!

1 Like

I have the GrovePi I2C-1 connected to GoPiGo I2C port. I had the LCD screen connected toI2C-3. I ran the scripts from our previous post with no sensors attached, just the GoPiGo board and the GrovePi. I haven’t done anything to the firmware (wouldn’t know how)

is it a big deal if my rovepi is seen on 08?

Hi @paul.reisinger,

It’s kind of a big deal not seeing address 0x04.
Address 0x04 is hard-coded into our firmware, so there’s no chance for the GrovePi to broadcast address 0x08.


Can you confirm us that you didn’t have anything connected to your GrovePi while you’ve ran the screenshot-ed tests?
Pictures can be useful, so can you take some photos of your setup?


Also, can you enter the following commands in Raspberry Pi's terminal - one after the another:

cd ~/Desktop
sudo mkdir updater
cd updater
sudo wget https://raw.githubusercontent.com/DexterInd/GrovePi/master/Firmware/grove_pi_firmware.hex
avrdude -c gpio -p m328p -U lfuse:w:0xFF:m
avrdude -c gpio -p m328p -U hfuse:w:0xDA:m
avrdude -c gpio -p m328p -U efuse:w:0x05:m
avrdude -c gpio -p m328p -U flash:w:grove_pi_firmware.hex

After these sequence of commands, please run i2cdetect -y 1 again and let us know what it prints out in the console.
Again, it’s important to disconnect anything that you might have attached to your GrovePi.


I’m waiting to see what is the outcome of these suggestions.

Thank you!

I just flashed a new SD - 2017.04.02_Dexter_Industries_jessie

Here are pictures. I started running commands. The one command screenshot. should I say Yes or No?

Hi @paul.reisinger,

Enter y (yes) every time it asks you.
Also, the photos look okay to me.

Thank you!

That did it, its on 04 now.

I’ll connect the uv sensor and run a test

OK, I think I’m back up and running!! Please excuse the UI design of the screenshot but my daughter and I are still working on it. I’ll get the camera back up and working tomorrow. I’m not sure what I did but the only thing I can think of is I chose NO “n” when I was updating firmware. Thank you sooo much!! My daughter and I really appreciate your dedication!

Hi @paul.reisinger,

I’m happy to hear you’re up and running.
This means a lot!

Your project seems interesting. At least that’s what I’m assuming when I see this GUI.
What is this project about?
And also, can you share more with us?

Thank you!

Well, my daughter (and I) are very interested in robotics so when I found dexter industries I was very excited. We purchased the GoPiGo starter kit and we put it together. With that success and my daughters quick success with scratch we decided to get the groovepi and more sensors. What we have going now is a UWP app that communicates to the raspberry pi via the python tornado web socket server. Basically extended the browser streaming robot example. I was also able to incorporate speech recognition using the uwp libraries, “Look Left, Look Right, What’s the temperature, How many faces do you see, etc” as well as facial detection from the mjpeg stream. We definitely want to continue adding features like autonomous movement, ai thinking (basic lol).

She has a hobby day next week so I’m trying to automate the startup of everything needed. Right now I have to input “sudo python ~/Dexter/GoPiGo/Software/Python/Examples/Browser_Streaming_Robot/robot_web_server.py” in the terminal to start the server but I don’t want her to have to do that. If I can get that script to run at startup then she could just launch the UI App and should be able to connect automatically. I bought a cheap netgear router so all she should have to do is plug in her equipment to power, the pi and notebook will auto connect to wireless and be on the same network and then she should be set to go.

such a great platform for beginners as well as to advanced!

Hi @paul.reisinger,

Well, that seems really fun to work on.
And it’s really great to hear your daughter has an interesting passion. That’s awesome!


Regarding the other issue you’ve brought the word about, I think you can easily do it by creating a service and enabling it with systemd to run on boot.

Here’s what you have to do:

Step 1

Use the following template to write your unit file - that’s how it’s called.

 [Unit]
 Description=My application name

 [Service]
 Type=idle
 ExecStart=/usr/bin/python /path/to/my/python/app.py
 Restart=always
 RestartSec=2

 [Install]
 WantedBy=multi-user.target

Step 2

Give this filename a name following this template: mywebservice.service.
Please, keep in mind that the extension must be .service.

Copy paste the file to /etc/systemd/system/ folder. You’ll need to use sudo for it.


Step 3

From within the terminal type the following commands:

sudo systemctl daemon-reload 
// reloads all the unit files - including our recently added one
sudo systemctl enable mywebservice.service
// enables the service -> it will make the app start on boot
sudo systemctl start mywebservice.service 
// enter this command so that you don't have to reboot 
// in order for the service to get started

Also, if you wish to disable the service use the sudo systemctl disable myservice.service.
If you wish to update the systemd with new changes brought to the unit file use sudo systemctl daemon-reload.
And for stopping the service use sudo systemctl stop myservice.service.

That simple!


Conclusion

Now, whenever the Raspberry Pi boots up, your program found at /path/to/my/python/app.py will get launched.
If the app fails to run, or during its operation it stops, it gets restarted after 2 seconds, no matter what.

If you want to restart the server and bring new changes that you’ve been working on, you can issue the following command:

sudo systemctl restart mywebservice.service

Hope this will get the software up and running for the next week, on hobby day.

Thank you!

Yeah! It’s been fun. I got the script to auto start by putting the sudo python ~path into rc.local. It works!

|690x0

Actually, I like your solution even better, running as a service. I’ll give that a shot! Thanks!!

Hi @paul.reisinger,

Can we close the thread now?
Is there anything else needed to be solved that’s also related to our topic’s subject?

Thank you!

Yes, you can close the thread. Thank you for all your help!