Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

Communication between multiple CP boards
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Communication between multiple CP boards

by Robin_101 on Thu Jul 23, 2020 7:34 am

Hi,

I am working on an educational project where I would like to take multiply CircuitPython boards (Circuitplaygrounds, Itsy Bitsy and Feather M0 express') and have them communicate with each other.

I am an experienced embedded developer but new to CircuitPython. I am looking for something like the standard Arduino I2C example of hooking up 2 Uno boards. Though there doesn't seem a way to set up a CircuitPython board as parent or child.

I am not picky about protocol and have also tried UART, but passes messages back and forth seems buggy at best.

I have looked through the examples but these all cover a board talking to a sensor, not 2 boards talking. Any advice would be welcome!

Thanks!
Robin_101
 
Posts: 8
Joined: Thu Oct 10, 2013 1:13 pm

Re: Communication between multiple CP boards

by danhalbert on Thu Jul 23, 2020 8:33 am

We have an `I2CSlave` (will be `I2CPeripheral in 6.0.0), but it is not included in most or all M0 (SAMD21) builds due to space.

UART is therefore the easiest choice. Are you seeing dropped bytes? That would be mostly due to buffer overflow, I'd think. It would be important to send short messages, and wait for ACK's back from the reciever before sending more. The ACK's could come back as bytes, or you could implement soft RTS/CTS flow control. We don't have support for hardware flow control.

Note that any boards that are sharing data lines need to have their grounds tied together. Did you do that in your UART testing? Otherwise they will not have a common voltage reference and the transmission will not work well.

danhalbert
 
Posts: 2073
Joined: Tue Aug 08, 2017 12:37 pm

Re: Communication between multiple CP boards

by Robin_101 on Thu Jul 23, 2020 12:00 pm

Thank you for your reply. It is a shame that I2CPeripheral will not be more widely available as this would be perfect!

I did pursue the UART option further and have implemented acknowledgments for message passing. After getting more familiar with the UART methods, .readline() provides a more reliable way of reading incoming bytes. .read() seemed to add erroneous 0x00 bytes. So I think it will be good enough for what I'm trying to achieve.

Thanks for the help.
Robin_101
 
Posts: 8
Joined: Thu Oct 10, 2013 1:13 pm

Please be positive and constructive with your questions and comments.