I’m incorporating an I2C display into my Boron project and have it working. I would like this display to be optional - i.e. the boron will run “headless” if the display is not attached. I also may incorporate future optional sensors via I2C. The problem I’m running into is that if the display is disconnected (or damaged) the Boron locks up completely when I try to initialize the display (Adafruit_SSD1306 library) or even scan the I2C bus.
How can I ensure that I2C operations don’t lock up the Boron, but instead return an error that I can handle in my code?
EDIT: The device lockup is not related to the Adafruit library. I tried a simple scan of the I2C bus with the display’s Vcc disconnected, and the Boron locked up on Wire.endTransmission(). Wire.begin() was of course called first, and the test works when the display has its Vcc pin attached.
Do you have pull-up resistors on the I2C pins when you run the bus scan?
Yes, I have 4.7k pullup resistors on SDA and SCL. I have tested both with and without them. Same result. Only when the I2C device isn’t present the Boron locks up. In that case, unless the display is shunting everything to ground, the pullup resistors are still in place on SDA and SCL.
I did a little more testing, and it appears that my OLED display is possibly causing the problem. If I pull the Vcc line from the display and reset the Boron, it hangs at initializing I2C. If I pull ALL pins from the display the Boron initializes properly. I’m going to look into a different display (this one is the 0.96 inch OLED display from DiyMall).
I’m having a similar issue with I2C lockup with a Boron 1.1.0 with a Bosch BMP388 sensor attached via I2C. At some point every few hours or days, the I2C bus appears to hang, then the watchdog timer expires and a reset is generated. When the Boron comes back online, the devices on the I2C bus are dead and not reachable so the Boron endlessly reboots every minute due to the watchdog timer expiring. Disconnecting power to the BMP388 and Boron brings everything back to life. (not good for a remote IoT device, so a better option is needed)
Nearly the same code and sensors are running on an Electron 3G and Argon (WiFi) without one lockup yet in four weeks on the Electron and a week on the Argon, so it is starting to look like a Boron only issue with the I2C not coming back to life after a soft reset (watchdog timer reset) or else the I2C may be somehow hanging the Bosch sensor.
Pull up resistors are used. Voltage on the I2C is 3.3V from the Boron and decoupling 100nF capacitors are in place next to the I2C IC voltage inputs.
Not a sloution but a possible workaround would be to supply the I2C sensors via a GPIO directly or a GPIO controlled FET which allows the watchdog reset to also reset the sensor at the same time.
1 Like
Excellent suggestion Scruff. Thanks.
@power64, I had the exact same issue with a BME280 sensor on a Photon. After some time, the sensor would stop responding. I ended up doing exactly what @ScruffR suggested and have never had the sensor lock up since.
1 Like