If you haven't already done so, be sure your board is added to the large if statement in Adafruit_Blinka/src/busio.py. See the I2C page for more details.

Next we'll work on getting SPI working. To get SPI working, you will first need to make sure your SPI is enabled. The exact method to enable it can vary from manufacturer to manufacturer. For the Pine64, we used armbian-config and enabled spi-spidev. You can check if it's enabled by typing the following command:

ls /dev/spi*

If it is enabled, there should be at least one SPI port listed.

Adding to the Chip File

Near the bottom of the Chip File, you'll want an spiPorts tuple variable that contains all of the SPI ports. It should end up looking something like the following:

Download: file
# ordered as spiId, sckId, mosiId, misoId
spiPorts = (

The values in each of the tuple items are as follows:

  • The SPI bus number. For instance, a value of 1 corresponds to /dev/spidev1.0. At this time, only Spidev device 0 is supported.
  • The SCLK or Serial Clock pin. This should be an alias for readability.
  • The MOSI or Microcontroller Out Serial In pin. This should also be an alias for readability.
  • The MISO or Microcontroller In Serial Out pin. This should also be an alias for readability.

Adding to the Board File

The only thing you will need to add to the board file are any aliases for the Pins.

Parts Used

To test, we'll need an SPI controlled board such as the MAX31855, which is a Thermocouple Amplifier sensor (for temperature measurement) along with a couple other parts to connect it to the board.

Some boards operate at a lower voltage than 3.3v and may need to be wired through a Level Shifter as well.

Thermocouple Amplifier MAX31855 breakout board (MAX6675 upgrade)

Thermocouples are very sensitive, requiring a good amplifier with a cold-compensation reference. The MAX31855K does everything for you, and can be easily interfaced with any...

Thermocouple Type-K Glass Braid Insulated

Thermocouples are best used for measuring temperatures that can go above 100 °C. This is a bare wires bead-probe which can measure air or surface temperatures. Most inexpensive...

Half-Size Breadboard with Mounting Holes

This cute 3.2″ × 2.1″ (82 × 53mm) solderless half-size breadboard has four bus lines and 30 rows of pins, our favorite size of solderless breadboard for...

Premium Female/Male 'Extension' Jumper Wires - 40 x 6" (150mm)

Handy for making wire harnesses or jumpering between headers on PCB's. These premium jumper wires are 6" (150mm) long and come in a 'strip' of 40 (4 pieces of each of ten rainbow...


  • Connect the SBC 3.3V power pin to Vin
  • Connect the SBC GND pin to GND
  • Connect the SBC SCLK pin to the MAX31855 CLK
  • Connect the SBC MISO pin to to the MAX31855 DO
  • Connect the SBC D5 pin to to the MAX31855 CS

Run the Test Script

After wiring it up, double-check your connections. Next, make sure the MAX31855 library is installed. If you chose a different sensor, make sure that library is installed:

sudo pip3 install adafruit-circuitpython-max31855

Next save the simpletest code to your board as max31855_simpletest.py:

import time
import board
import busio
import digitalio
import adafruit_max31855

spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
cs = digitalio.DigitalInOut(board.D5)

max31855 = adafruit_max31855.MAX31855(spi, cs)
while True:
    tempC = max31855.temperature
    tempF = tempC * 9 / 5 + 32
    print("Temperature: {} C {} F ".format(tempC, tempF))

Now go ahead and run that code using the following command:

sudo python3 max31855_simpletest.py

You should see it outputting the temperature every 2 seconds or so:

You will want to perform the same test procedure on each SPI port that you want to test. Be sure to change both your wiring and the corresponding pins in the test script if necessary.

Troubleshooting Tips

  • Make Sure SPI is enabled on your board
  • Try a different GPIO for the Chip Select Pin
  • Check your Wiring
  • The board may just not support SPI. It often doesn't work for us.
This guide was first published on Apr 01, 2020. It was last updated on Apr 01, 2020.
This page (Getting SPI Working) was last updated on Oct 25, 2020.