I2C_SOFTRESET

February 7, 2025 ยท View on GitHub

Arduino CI Arduino-lint JSON check GitHub issues

License: MIT GitHub release PlatformIO Registry

I2C_SOFTRESET

Arduino library for the I2C_SOFTRESET, to reset stuck devices.\n Sends a soft reset over the I2C bus.",

Description

Experimental

The I2C_SOFTRESET is a library to reset some stuck devices on the I2C bus.

After an error during the I2C handshake, power problem or reset an I2C device can get stuck. Some devices can get unstuck after an I2C bus reset.

The I2C specification defines a I2C bus reset as follows:

A START pulse, followed by 9 pulses, followed by a START and STOP pulse on the SCL line.

SCL   H L   H L   H L   H L   H L   H L   H L   H L   H L   H L   H L   H L   H L
     START   1     2     3     4     5     6     7     8     9   STOP  START  STOP

SDA    L H                                                               L     H

Feedback, issues, improvements are welcome. Please file an issue on GitHub.

Interface

#include "I2C_SOFTRESET.h"
  • I2C_SOFTRESET(uint8_t SDA, uint8_t SCL)
  • void reset() sends the I2C reset pulse.
  • uint32_t lastReset() returns timestamp of last reset if one was not enough.

There is also a function that does all in one call.

  • void I2CSoftReset(uint8_t SDA, uint8_t SCL) sends the I2C reset pulse.

Future

Must

  • improve documentation
  • test the library with hardware (how to get a device stuck?)

Should

  • add examples
  • optimize where possible.
  • parameter for the delayMicroseconds();

Could

  • class I2C_BUS(SDA, SCL)
    • generic calls too into class? I2C_GENCAL class?

Wont

Support

If you appreciate my libraries, you can support the development and maintenance. Improve the quality of the libraries by providing issues and Pull Requests, or donate through PayPal or GitHub sponsors.

Thank you,