MCP23017 switches randomly out of a sudden

I have a manual switch (Quality from ATEM) to ground on a MCP23017.

The soft part is

#include <Adafruit_MCP23X17.h>
Adafruit_MCP23X17 mcp;
 mcp.pinMode(0, INPUT_PULLUP);  
 mcp.pinMode(1, INPUT_PULLUP); 

and
if ((mcp.digitalRead(0) == 1) && (mcp.digitalRead(1) == 1)) {

Now this runs for hours or days, even weeks without any issue. And then, at a random time out of a sudden this if statement becomes true, without even touch the switch.

I post this in this category because i can not say if it's a hardware or a software issue.

Any hints, experiences?

Thank you

Incorrectly handled millis() / micros() overflow?
Post your code and a schematic and state how you have observed this issue for other suggestions.

1 Like

Tell us about the wiring between the switch and the MCP, and about the i²c bus wiring.

With so little information to go on, all that forum members can do is guess, which is frustrating for them and for you. Read the forum guide, in the sticky post at the top of most forum sections, for advice about what to include when you ask for help on the forum.

I will take a SWAG as what you are sort of describing is a common mistook. The pull up resistors are not strong enough for reliable operation. As requested post your schematic as you have it wired. A frizzy picture in useless. Also post a link to each of the hardware items that gives technical details. Azon and others have sales info but not technical information. You state "MCP23017" That is a chip which you have to be mounded somewhere and have wired it, that is important.

Sorry for the delay and the missing schema.

Arduino

Bildschirmfoto 2022-10-01 um 05.24.55
TCA4311 Hot Swappable 2-Wire Bus Buffer


MCP:

The switch is wired directly from GPA0 & GPA1 to GND.

Links:
MCP23017 :

TI I2C HotSwapBuffer:

Change your pull up resistors for maybe 4.7K for 5V and 3.3K for 3V3. Assuming the level shifter is wired correctly it should work. Run the I2C scan to verify that. This resistor change does two things for you. It lowers the impedance of the I2C circuits decreasing there sensitive to electrical noise. It also increases the switching speed from low to high giveing you a bit more time to get the message decoded. This is accomplished by overpowering the capacitance in the wiring.

You show a decoupling cap for the MKR. I don't see one mentioned for the MCP23017 or the TCA4311A.

I will try out, thanks. I implemented meanwhile a software solution as a workaround.

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