Page 1 of 1

Wire does not always connect to I2C properly

Posted: Sun May 10, 2020 6:58 am
by kvv213
Hello All!

I've faced a strange problem that I don't understand how to solve properly.

I have stm32f103 chip that is connected with en EEPROM via I2C. I use STM32Duino core and work with EEPROM via Wire lib. In the most cases everything works well and I connect to I2C EEPROM and can read and can write.

But sometimes, at very rare cases, I can't connect to I2C properly. In the meaning that I connect to it with the same mannor and it seems to be connected. But when I read it returns something random and when I try to write it doesn't. At the same time no errors is returned at all. So from Wire it looks like everything is fine.

So, what shall I do in that way? How to determine that I2C is connected properly? And how to reconnect if I see that there is a problem?

PS. The first thing that comes in my mind - try to write something and read it back. If the value is correct then continue to work otherwise - reboot. But it doesn't seems to be a good solution.

PSS. The code for init:
Wire.setSCL(I2C_SCL);
Wire.setSDA(I2C_SDA);
Wire.begin();

PSS. EEPROM that I use is AT24C08

Re: Wire does not always connect to I2C properly

Posted: Sun May 10, 2020 4:41 pm
by fpiSTM
The next release will include several bugfixes for I2C maybe this will solve your issue

Re: Wire does not always connect to I2C properly

Posted: Thu Mar 09, 2023 9:48 am
by hennysmath
One approach to detecting and resolving this issue is to use a handshake protocol between the STM32 and the EEPROM. For example, you could send a specific byte sequence to the EEPROM and expect a specific response ovo game If the response is not what you expect, then you can assume that the connection is not working properly and take appropriate action (such as resetting the I2C bus or resetting the STM32).