# I2C Bus Lockup / Reset

**URL:** <https://community.particle.io/t/i2c-bus-lockup-reset/63564>\
**Category:** Firmware\
**Created:** [November 22, 2022, 4:18pm UTC](https://community.particle.io/t/i2c-bus-lockup-reset/63564 "2022-11-22T16:18:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![superpanda](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@superpanda](https://community.particle.io/u/superpanda)\
**Post date:** [November 22, 2022, 4:18pm UTC](https://community.particle.io/t/i2c-bus-lockup-reset/63564/1 "2022-11-22T16:18:08Z")

</div>

I discovered a situation where the I2C bus locks up on my Argon OS v4.0.0. I am taking steps to eliminate the cause of the bus lockup, but once it occurs a power cycle is the only way to recover. Trying to be considerate of the edge case where this could happen again, I want a way to recover from this state without a power cycle (these are devices are installed in remote locations)

In refrence to : [I2C can lock up Boron](https://community.particle.io/t/i2c-can-lock-up-boron/49546)

One solution is to place all my devices on a switched power bus. Unfortunately, adding that bus to the current board design would be very difficult.

Is there another strategy to resolve a locked-up I2C bus through software? I was hoping a Wire.reset() would break whatever loop the library was stuck in, but it does not.

Any sugestions appreciated.

---

<div class="post-metadata">

**Author:** ![superpanda](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@superpanda](https://community.particle.io/u/superpanda)\
**Post date:** [November 22, 2022, 6:58pm UTC](https://community.particle.io/t/i2c-bus-lockup-reset/63564/2 "2022-11-22T18:58:57Z")

</div>

The more I look at this, if the issue is due to a device that uses clock stretching I am not sure it’s possible for the master to recover. That device could lock up the bus by holding the clock low. Only a power reset (or pin reset if it has one) of the errant device would do it…I think.

I am using an SHT30 temperature sensor and I can create a situation where the slave device gets stuck holding the clock low and only a power reset can resolve it.

---

<div class="post-metadata">

**Author:** ![rickkas7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rickkas7/32/8681_2.png) [@rickkas7](https://community.particle.io/u/rickkas7)\
**Post date:** [November 22, 2022, 7:53pm UTC](https://community.particle.io/t/i2c-bus-lockup-reset/63564/3 "2022-11-22T19:53:13Z")

</div>

It looks like Wire.reset() should be able to be called in that circumstance, and it does a lot to try to free the bus:

> <https://github.com/particle-iot/device-os/blob/develop/hal/src/nRF52840/i2c_hal.cpp#L676>

If that’s not working, then the only alternative is probably to pull the power to the sensor.

---

<div class="post-metadata">

**Author:** ![superpanda](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@superpanda](https://community.particle.io/u/superpanda)\
**Post date:** [November 22, 2022, 11:11pm UTC](https://community.particle.io/t/i2c-bus-lockup-reset/63564/4 "2022-11-22T23:11:13Z")

</div>

Agreed, if the master can fix it Wire.reset() should work. However, I am now finding that I can get the SHT30 in a state where it keeps the SCL low with no way to recover from the master.

-AP

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/3/2/3291e3c9351789fe8620ae5bcec8d3fec67ff221.png) [@system](https://community.particle.io/u/system)\
**Post date:** [December 23, 2022, 9:12am UTC](https://community.particle.io/t/i2c-bus-lockup-reset/63564/5 "2022-12-23T09:12:04Z")

</div>

Closed on December 23, 2022, 9:12am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
