SPI synchronization between two devices

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: SPI synchronization between two devices

Post by Roberthh » Tue Feb 02, 2021 8:28 pm

nina-fw from Adafruit.
Using that the slave mode for Micopython would not be required.

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: SPI synchronization between two devices

Post by kevinkk525 » Tue Feb 02, 2021 9:44 pm

exactly. the firmware is already done and has spi slave in c++. And the client side (e.g. rpi pico) uses SPI master. So no SPI slave needed in micropython.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

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

Re: SPI synchronization between two devices

Post by pythoncoder » Wed Feb 03, 2021 1:19 pm

There is a potential snag with SPI.
Peter Hinch
Index to my micropython libraries.

nico314
Posts: 7
Joined: Tue Feb 02, 2021 4:08 pm

Re: SPI synchronization between two devices

Post by nico314 » Wed Feb 03, 2021 8:26 pm

Seems the CircuitPython firmware does not work on ESP32, unfortunately. So the two emerging solutions would be to use UART (up to 5Mbit/s) or run an SPI slave (theoretically up to 10Mbit/s) on the ESP32 board by programming it directly in C/C++. I had a look at the Espressif SDK, there is a module dedicated to SPI slave. Seems they have it all covered, with a complete API and docs and even a good-looking example. If that's really working code, wrapping it up in an mpy module should not be too hard.
Kevin: keep us updated about your findings?
Thanks!

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: SPI synchronization between two devices

Post by Roberthh » Wed Feb 03, 2021 8:39 pm

There is a fork of the nina-fw used by sipeed. They have an ESP32 as wifi-copro for their MAxduino product, which itself uses MicroPython.
https://github.com/sipeed/Maixduino_esp32_fimware
So maybe you can get some inspiration from that. At a first glimpse I did not see much of documentation.

P.S.: Using an ESP32 as WiFi modem for an RP2040 seems odd, as we say in German (oddly translated) "throwing the ham at the sausage". There are other products with the rp2040 announced which have it at least all integrated in one module: https://blog.arduino.cc/2021/01/20/welc ... ntrollers/

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: SPI synchronization between two devices

Post by kevinkk525 » Wed Feb 03, 2021 9:06 pm

nico314 wrote:
Wed Feb 03, 2021 8:26 pm
Kevin: keep us updated about your findings?
Absolutely. I flashed the nina-fw firmware onto my esp32 and a test sketch onto another esp32 but having trouble getting the wiring correctly done and it doesn't get a connection. I have posted on the adafruit forum and hoping for a reply.
It was a rather frustrating adventure diving through different documentations and even the code itself to actually see which pins are used because in all documentations they only refer to the pin labels on their adafruit boards which are nowhere to be found on my standard nodemcu esp32s and some pins (e.g. gpio0) aren't even exposed on these but used in the project..
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

nico314
Posts: 7
Joined: Tue Feb 02, 2021 4:08 pm

Re: SPI synchronization between two devices

Post by nico314 » Wed Feb 03, 2021 10:19 pm

Robert: agreed, there are better solutions out there. Point is to provide some networking features to a microcontroller board that doesn't have any, making use of whatever hardware I happen to have on my desk -- and I have tons of cheap ESP32s gathering dust. The Arduino/Pico board is still weeks or maybe months away and I kind of like the idea of connecting several boards together to build something smarter than its individual components, possibly enhancing existing libraries or porting other pieces of firmware while doing so.
Didn't know the expression with sausage and ham :-) In French they use a power hammer to smash flies.

Kevin: I feel your pain. Every one of my microcontroller boards has a different pin layout. The TTGO ones vary from one version to the next, it drives me crazy.

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: SPI synchronization between two devices

Post by kevinkk525 » Thu Feb 04, 2021 9:02 pm

Please see this thread for future updates: viewtopic.php?f=21&t=9664&p=54429#p54429
(Just updated it with my results from today)
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

Post Reply