Page 3 of 3

Re: PyB-to-PyB using I2C?

Posted: Sun Apr 07, 2019 8:08 am
by rhubarbdog
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

Re: PyB-to-PyB using I2C?

Posted: Sun Apr 07, 2019 8:12 am
by pythoncoder
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.

Re: PyB-to-PyB using I2C?

Posted: Sun Apr 07, 2019 9:51 pm
by OutoftheBOTS_
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.

Re: PyB-to-PyB using I2C?

Posted: Mon Apr 08, 2019 2:28 am
by mattyt
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...

Re: PyB-to-PyB using I2C?

Posted: Mon Apr 08, 2019 8:40 pm
by OutoftheBOTS_
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 :(