RPI i2c sensor loses visibility after about hour of use or GPIO pin access

Something strange happening to my app on raspberry pi3.

I have i2c and i2c is connected to my app.
There is a sensor connected to the i2c-1 bus (BME280)

The sensor works through my app for about an hour where every minute it would broadcast the sensor values via mqtt.

However; For some reason, after around an hour, the sensor is suddenly unavailable.

I installed and ran snappy-i2c-tools to diagnose.

When the rpi3 was just powered on I get the following:

$ sudo snappy-i2c-tools.i2cdetect 1
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-1.
I will probe address range 0x03-0x77.
Continue? [Y/n] y
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- 77 

Which is exactly what I expect.
But after about an hour when my app stops working, the same command gives me:

$ sudo snappy-i2c-tools.i2cdetect 1
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-1.
I will probe address range 0x03-0x77.
Continue? [Y/n] y
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- -- 

The only way to get this working again is to completely power down the pi, and power it up again.
Does anyone know why this might be happening? I’m not sure if this is a issue with rpi3, sensor or ubuntu core i2c interface.

EDIT: Oh yes, the i2c device also loses visibility when one of my (gpio) pins turn a relay on/off

i have various pi’s here (all 3 b+) with i2c attached OLED displays and one with a servo hat, neither show this behaviour. could this be a power issue ?

Not sure. I’m not that familiar with hardware. I’m using a RPI power adapter connected to the micro usb port.
A engineer I spoke to also suggested this might be power supply issue. The sensor is connected to the 5v power pin on the PI, so I wouldn’t think that’s the issue there.

I might try to diagnose this a bit later by removing all the relays and seeing what happens then.

It seems unlikely to me that snap confinement or Ubuntu Core would affect anything here, have you tried running the same snap outside of confinement on a Ubuntu Server classic image on the Raspberry Pi? It could also be a faulty I2C sensor that stops responding after some amount of time for some reason.
For debugging this type of hardware issue, I would typically use a digital logic analyzer to see if the clock lines are at least working for this sensor.

Yeah, I’ve run our app now for a couple of hours with the relay board disconnected (including all the pins).
Sensor stays on and visible, so this was indeed a power supply issue.

2 Likes