Page 1 of 1

what is the proper way to reset I2C after an error? Is there a Wire.reset()?

Posted: Sun Nov 14, 2021 6:17 pm
by mchahn
Way back in 2017 there was a post here about not being able to reset the I2C state after an error: viewtopic.php?f=14&t=3152. One of the replies said ...

"A reset method is now available in the Arduino master for the Wire library. You can use it as a part of recovery of the I2C under your own control.": viewtopic.php?p=14936#p14936
I am writing my app now that uses I2C. I want to handle errors properly but I have stared at the Wire code for some time and cannot find any reset. Using Wire.reset() doesn't compile.

What is the correct procedure I should use?

Re: what is the proper way to reset I2C after an error? Is there a Wire.reset()?

Posted: Wed Nov 24, 2021 12:38 am
by rodmcm
The latest Wire.h at https://www.arduino.cc/en/reference/wire only has limited commands
Usually a failure to read is handled by external programming such as "if Value>0 then ok else fault"
You can also detect with available() which returns the no of bytes that can be read