Pico as I2c peripheral

RP2040 based microcontroller boards running MicroPython.
Target audience: MicroPython users with an RP2040 boards.
This does not include conventional Linux-based Raspberry Pi boards.
Post Reply
1944john
Posts: 1
Joined: Mon Jul 04, 2022 11:29 pm

Pico as I2c peripheral

Post by 1944john » Tue Jul 05, 2022 4:47 pm

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

User avatar
scruss
Posts: 360
Joined: Sat Aug 12, 2017 2:27 pm
Location: Toronto, Canada
Contact:

Re: Pico as I2c peripheral

Post by scruss » Tue Jul 05, 2022 6:51 pm

there's the outline implementation here: Use Pico as an I2C peripheral?

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Pico as I2c peripheral

Post by jimmo » Wed Jul 06, 2022 2:20 am

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.

Post Reply