I’m running 1.4.4 on a Boron.
I’ve got a port expander (TCA9535) attached to Wire that does multiple things:
- Controls 2 relays
- Controls 8 LEDs
- Controls 6 other peripherals
The LED controls are run inside a Timer that fires every 63ms. The relay controls and other peripherals are done through the application loop on an ad-hoc basis. The other peripherals are turned on and off every second or two.
In testing I’ve found that the Relays will turn on or off for no reason I can tell. I’ve done enough testing to know its not my application code.
The issue only started happening when I introduced the LED Timer. I’ve had issues with Timers or other multithreading in the past, so now I think I could be having a collision on the port expander when the Timer fires.
This prompted me to try SINGLE_THREADED_BLOCK around I2C calls. This hung my application within 1 second of resetting.
I’m now using WITH_LOCK(Wire). It seems to be working, but as far as I can tell from the forum and documentation, this is not supported. Can someone chime in to say whether this is a supported approach? Is there some other approach that might be better?