I have an I2C communication problem with my Raspberry Pi 3b.
My program in python reads and writes every 6s on the I2C port. Everything works perfectly for several days. For no particular reason, the SMBus library returns an error 121 and then it no longer works. The bus no longer works and you have to restart the whole system for it to work again.
Here is the list of equipment:
- I2C Shield for Raspberry Pi 3 & Pi2 with Outward Facing I2C Port
- SHT25 Humidity and Temperature Sensor ±1.8%RH ±0.2°C I2C Mini Module
- Analog Devices AD5254 Digital Potentiometer 4-Channel 256-Position I2C Mini Module
- 8-Channel General Purpose SPDT Relay Controller with I2C Interface
They are all linked on the shell and it works until the problem mentioned.
What can be the problem? Can a component cause a complete port failure?
Is there a way to reset the port in python after after several errors?
Thanks for your help.
This is honestly a bit outside of our technical support area. My suspicion is that this is code or library related as our devices being present on the I2C port should not cause an issue like that.
My suggestion would be to replicate the error. Once the error occurs stop the python script. Then use something like I2C Tools in the terminal to manually communicate with the devices and see if the I2C bus is still functional. If it is then you have narrowed down the issue to the SMBus Python Library and can proceed in that direction. If however you cannot communicate to the devices over the I2C bus using a secondary software then let us know.
Thank you for your help.
I will try but I do not know why the problem occurs.
I wonder, the temperature sensor cable is almost 4 meters. Is it possible that the cable impedance is not good? Does your hardware support a lower bit rate, i2c_arm_baudrate = 40000 for example?
I would certainly say that is unconventional. Try shortening the cable and testing again. You might also try installing the I2C pull up jumper on the sensor to see if that helps.
I2C Bus Speed is not really anything we control on these products. It depends on the manufacturer of the IC on the product. You can take a look at your product’s IC Datasheet and see what speeds it supports.