Next you'll want to 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:
# ordered as spiId, sckId, mosiId, misoId spiPorts = ( (0, SPI0_SCLK, SPI0_MOSI, SPI0_MISO), (1, SPI1_SCLK, SPI1_MOSI, SPI1_MISO), )
The values in each of the tuple items are as follows:
- The SPI bus number. For instance, a value of 1 corresponds to /dev/spidev0.1. At this time, only Spidev 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, you'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.




- 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:
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # SPDX-License-Identifier: MIT import time import board import digitalio import adafruit_max31855 spi = board.SPI() 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)) time.sleep(2.0)
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:
Page last edited January 22, 2025
Text editor powered by tinymce.