mcauser/micropython-mcp23017

Random OSError: [Errno 5] EIO

Opened this issue · 0 comments

Hi,

I am using this library to connect an MCP23017 to a Raspberry Pi Pico. Randomly, every few minutes, the code crashes with the following error:

Traceback (most recent call last):
File "", line 17, in
File "mcp23017.py", line 263, in pin
File "mcp23017.py", line 144, in gpio
File "mcp23017.py", line 73, in _read
OSError: [Errno 5] EIO

I build a very simple circuit on a protoboard to debug the issue, right now its just a Raspberry Pi Pico and an MCP23017. The code I'm running is also as simple as possible:

from machine import I2C, Pin, RTC, ADC, SPI, UART
from mcp23017 import MCP23017

Set-up the I2C bus.

i2c_bus = I2C(1,
scl = Pin(19),
sda = Pin(18),
freq = 10_000)

Set-up the MCP23017 I/O expander.

IO_expander = MCP23017(i2c_bus, 0x20)

while (True):
button_UP = IO_expander.pin(0)
button_DOWN = IO_expander.pin(1)
button_MODE = IO_expander.pin(2)
button_PULSE = IO_expander.pin(3)
button_DIS_ARM = IO_expander.pin(4)

print(" ")
print(str(button_UP)+" : "+str(button_DOWN)+" : "+str(button_MODE)+" : "+str(button_PULSE)+" : "+str(button_DIS_ARM))

Could you please tell me what might be wrong here? The code works perfectly fine for a few minutes and then crashes at random times.

Thanks!
Best,
Diego