I got the same OSError: [Errno 5] EIO error on a Raspberry Pi Pico W with I2C code that worked without error on a Raspberry Pi Pico. I didn’t see the fix that worked for me mentioned in this thread so I’ll add it here as an appendix to this old thread.
I found the cause was that some versions of MicroPython (machine.I2C) use different default pin allocation for SCL and SDA between the Pico and the Pico W. From I2C broken on RPi Pico-w v1.20.0-50-g786013d46 (and previous 1.20.0) · micropython · Discussion #11429 · GitHub
…For the RPi Pico (not W) running MicroPython v1.20.0 on 2023-04-26, the default pins seem to be
I2C Configuration: I2C(0, freq=399361, scl=5, sda=4, timeout=50000)
I2C Configuration: I2C(1, freq=399361, scl=7, sda=6, timeout=50000)
…
For the RPi Pico-W running MicroPython v1.20.0-50-g786013d46 on 2023-05-04, the default pins are the same as the non-W Pico…
The fix for me was to define the pins explicitly:
i2c = I2C(freq=400000, id=0, sda=Pin(8), scl=Pin(9))
With this change the same code worked on the Pico W and the Pico. I haven’t yet seen this issue affecting PiicoDev device libraries.
Peter