PyB-to-PyB using I2C?

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
rhubarbdog
Posts: 168
Joined: Tue Nov 07, 2017 11:45 pm

Re: PyB-to-PyB using I2C?

Post by rhubarbdog » Sun Apr 07, 2019 8:08 am

I think @pythoncoder created an i2c to i2c comms with uasyncio and an extra wire to wake each other up. It looked interesting but i didn't have multiple devices at the time to test it. Search his repositories on github

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: PyB-to-PyB using I2C?

Post by pythoncoder » Sun Apr 07, 2019 8:12 am

I did indeed ;)

The Pyboard is rare in that it supports slave mode. My asynchronous driver enables a Pyboard to communicate with any MicroPython device using I2C. It may be found in this repo. The link is notionally full duplex in that either node can initiate a transfer. However there is some latency involved: this is explained in the docs.

It has not yet been tested on the Pyboard D, but it works for Pyboard to Pyboard and Pyboard to ESPx links.
Peter Hinch
Index to my micropython libraries.

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: PyB-to-PyB using I2C?

Post by OutoftheBOTS_ » Sun Apr 07, 2019 9:51 pm

Lobo port does have a full working I2C slave mode. I have tested a number of version of Micro-Python I2C slave and it is the only one that has worked as a standard I2C slave.

The STM32 port does have I2C slave mode but the the MCU must be constantly testing for a transmission from the master or the master will get a NACK back. This means the MCU can't go off and do other things or the master gets a NACK.

Lobo ESP32 port uses a hardware interrupt on the I2C line to interrupt what ever MCU is doing and write/read from a predefined array that acts like the I2C register or you can set it to trigger a python call-back. This means that the MCU can be off doing what ever it likes and when the master starts a transmission the slave will be interrupted if it is off doing something else.

User avatar
mattyt
Posts: 410
Joined: Mon Jan 23, 2017 6:39 am

Re: PyB-to-PyB using I2C?

Post by mattyt » Mon Apr 08, 2019 2:28 am

I briefly touched on implementing I2C slave on ESP32 (using Boris' implementation as a guide). The implementation should be reasonably straightforward. But 3935 should be resolved first since the API for I2C slave is not well defined...

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: PyB-to-PyB using I2C?

Post by OutoftheBOTS_ » Mon Apr 08, 2019 8:40 pm

mattyt wrote:
Mon Apr 08, 2019 2:28 am
I briefly touched on implementing I2C slave on ESP32 (using Boris' implementation as a guide). The implementation should be reasonably straightforward. But 3935 should be resolved first since the API for I2C slave is not well defined...
I did write in C a software I2C slave for a STM32F103 (AKA blue pill). It used an HW interrupt that fired when when the SDA line got pulled low (this is how the master starts a transfer). When the interrupt fired then it disabled the interrupt and then did the transfer in SW, the transfer would read or write to an array that acted like the I2C register then after it was finished then it re-enable the interrupt and returned to normal execution of program. If your interested in it the code is here https://github.com/OutOfTheBots/I2C_Slave-STM32f10x do be aware that this was my first ever attempt at writing in C so it maybe a little hard to follow and not the best set out :(

Post Reply