Page 1 of 1

Pico as I2c peripheral

Posted: Tue Jul 05, 2022 4:47 pm
by 1944john
Any idea when micropython will support I2c on the PICO as a peripheral device?

I (think) I understand the timing issue and found I2CResponder on GitHub. Uses one of the cores to handle the net. Seems like an excellent idea but the example program uses one Pico talking to itself. I’m finding it difficult to split the code for two picos. That’s a reflection of my skills - not the code!

A few years back I got a network of 3 Arduino working with no problem but that was using c++ but have no desire to go back there.

Any suggestions or advice?

Thanks

Re: Pico as I2c peripheral

Posted: Tue Jul 05, 2022 6:51 pm
by scruss
there's the outline implementation here: Use Pico as an I2C peripheral?

Re: Pico as I2c peripheral

Posted: Wed Jul 06, 2022 2:20 am
by jimmo
1944john wrote:
Tue Jul 05, 2022 4:47 pm
Any idea when micropython will support I2c on the PICO as a peripheral device?
This is something that gets discussed occasionally (not specifically for Pico but for all ports). We do have an implementation for the STM32 port. See https://github.com/micropython/micropython/issues/3935 for a pretty good summary. It's a useful feature and it would be great to support across more ports.

The issue with supporting a generic i2c peripheral from MicroPython is that it's very timing sensitive, although I2C does support clock stretching so maybe there's some leeway. Anyway, the likely approach will be to support defining a set of registers that can be read/written, with asynchronous callbacks when the controller writes to them. Supporting a read callback might be out of scope. But all still TBD.