For Part 1 see SAMD21 using SPI

We already saw how to initiate SPI communication between a Pi and a SAMD21 (e.g. Adafruit Feather M0). Initially we had some issues using Python and that is why we used C++ instead. But this example also works very well.

 J.A. Korten March 10, 2018
  Modified based on code by joan
#!/usr/bin/env python

# 2016-03-18
# Public Domain

import time

import pigpio #

pi = pigpio.pi()

if not pi.connected:

h = pi.spi_open(0, 40000)

stop = time.time() + 120.0

n = 0

while time.time() < stop:

   n += 1
   pi.spi_xfer(h, "Hello Arduino {}\n".format(n))




Now the only thing left is doing the reverse: sending text from the Arduino (SAMD21) to the Raspberry Pi. Some inspiration (for now):

Note: this is not yet tried for the SAMD21 and still in C++ for the Raspberry Pi side where I would prefer it to be Python there.

See also:

To finish things off Part 3: Bi-directional communication between a Pi and a SAMD21.