Grove i2c Touch in Python requires sudo and crashes sensors


Hi everyone

I’m running a collection of environmental sensors and an i2c touch controller (with 4 touch sensors) on my GrovePi.

First of all, the i2c touch demo program ( requires sudo to run, is this correct? I’m using Raspian and the default “pi” user.

Secondly, when I copy the demo code in my own program (and run as sudo to make it work), it somehow manages to interrupt certain sensors, making the try: return always fail.

The sensors which fail are:
Air quality (analogRead)
Loudness (analogRead)
Temperature & Humidity (dht)

The ones which still work are:
Pressure (bmp.readPressure())
Barometer temperature (bmp.readTemperature())
Lux (complex but I’m using digital_light_lux())
Motion (digitalRead)

I should point out that the loops to listen to the touch sensor and get the sensor data are running on different threads.

The strangest thing is that the problem remains until the Pi is shutdown and restarted again.

Does anyone have any ideas of why this may be happening? Or a different way of using the i2c touch in Python?



This might be a deeper issue:
I’m now trying to use a simple button instead of the i2c touch sensors, and whenever the motion sensor is detecting motion, the button is being returned as pressed. They are definitely set up on different digital ports in Python. I’ve tried moving the button to a different port with no luck. I think it’s also causing an issue with the temp & humidity sensors on port D7.


Hey JamesC,
Can you post the code that you are using. Also are you using the Dexter Industries Raspbian for Robots image or the Pi foundation’s image. Can you run i2cdetect -y 1 before starting the program and after the program stops responding. Can you run this: and tell us the firmware version it reports. Did you try running the program without threads. The I2C code is not thread safe and might cause some problems.