Arduino SPI Slave to Pi Zero Master

Hello, I'm looking for some guidance regarding the following idea I've just started trying to implement but have had some trouble getting it working.

For a TLDR of the below, has anyone recently established SPI communication between an arduino board and a Pi using a python script on the Pi end? Any good examples that are recent would be very helpful. I've tried using 3 python3 libraries without success; spidev, python3-spi, and wiringpi.

First I am aware of the different operating voltages, 5V for the Arduino's and 3.3V for the Pi's, and have some level shifters soldered.

I started from this point as inspiration: Overview | Program an AVR or Arduino Using Raspberry Pi GPIO | Adafruit Learning System

Just flashing the sketch to the Arduino over SPI is supposedly safe without the logic level shifter because it's going low to high but trying to get a signal back, 5V to 3.3V, can damage the Pi from what I've read. With the level shifter installed I have successfully flashed multiple sketches to an uno without issue.

Where I'm stuck now is establishing the SPI communication between the devices. Avrdude flashes just fine from the pi to the uno but I can't even get a signal to pass between the boards after flashing a sketch. I started with this example between two uno's and they shared the message successfully: Arduino SPI Communication Example | Circuits4you.com

Then I connected the Uno with the slave sketch to the Pi. Note, I did use the standard SPI pins on the GPIO pinout, rather than using custom MISO, MOSI, & SCK as in the Adafruit example above.

My sketch is so basic, the Uno slave now doesn't even process any data or print to serial, it's interrupt routine now just has a boolean in it that registers whether it received anything at all which looks like this:

ISR (SPI_STC_vect)
{ // SPI interrupt routine: SPI.attachInterrupt();  
  received = true;
}

Then I have it in my void loop to just blink in response as it wasn't sending a response like it was. But after trying many different examples i've not got anywhere. If any of you have some useful resources or recent examples that's really what I'm looking for.

With "spidev" I know I can only use 2 slaves as it uses the CE0 & CE1 pins by default, but wiringpi should be able to control more than two in a manner like this: Using Multiple SPI Slave Devices with the Raspberry Pi – Aditya Kedia

Thanks!

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.