[solved] sensors reading without being root



I have tried to run the example script grove_temperature_sensor.py as the pi user (from brick pi distro) but I get the following

pi@raspberrypi2 ~/Desktop/GrovePi/Software/Python $ python grove_temperature_sensor.py
Traceback (most recent call last):
  File "grove_temperature_sensor.py", line 5, in <module>
    import grovepi
  File "/home/pi/Desktop/GrovePi/Software/Python/grovepi.py", line 22, in <module>
    bus = smbus.SMBus(1)
IOError: [Errno 13] Permission denied

So, of course it works well when run with sudo.

My question is, is it possible to run this kind of script without sudo ?



You should run sudo adduser pi i2c and then reboot the Pi. I2C should be available without root after this. Do try this out and let us know if this works for you.

Thanks for pointing this out, we’ll get this in the newer image too so that it’s easier for people to access the I2C bus.




Thanks for your quick reply. Yes it does work :-). No need to reboot though, just restart my session.