Knowledge Base

The AB Electronics UK Knowledge Base provides support solutions, tutorials and troubleshooting guides.

Knowledge Base

SPI on the Tinker Board

Configuring the SPI bus on the Asus Tinker Board

The Asus Tinker Board contains two SPI buses on the 40-pin GPIO header named SPI0 and SPI2, as shown in the image below. 

SPI layout

SPI0 uses the following pins:

11: SPI0CLK (Clock Output)
13: SPI0_TXD (Transmit)
15: SPI0_RXD (Receive)
29: SPI0CSN0 (Cable Select 0)
31: SPI0CSN1 (Cable Select 1)

SPI2 uses the following pins:

19: SPI2_TXD (Transmit)
21: SPI2_RXD (Receive)
23: SPI2CLK (Clock Output)
24: SPI2CSN0 (Cable Select 0)
26: SPI2CSN1 (Cable Select 1)

Note: On the Raspberry Pi, the SPI bus on pins 19 to 26 is called SPI0; on the Asus Tinker Board, it is called SPI2. To use any software designed for the Raspberry Pi, you may need to change the SPI address to 2 to use it on the Tinker Board.

This page details how to set up SPI support for the SPI2 bus, which is used by most Raspberry Pi compatible hats and expansion boards, including those from AB Electronics UK.

Step 1: Download the latest TinkerOS Debian image for your Tinker Board and burn it to your SD Card following the instructions on http://elinux.org/RPi_Easy_SD_Card_Setup

Step 2: Next, you need to update your Tinker Board to ensure all the latest packages are installed:

sudo apt-get update
sudo apt-get upgrade

Step 3: Once you have updated your Tinker Board, run the following command to install the Python smbus and dev packages:

sudo apt-get install python3-smbus python3-dev

Step 4: Edit the /boot/config.txt file using nano or your preferred text editor:

sudo nano /boot/config.txt

Uncomment the line "intf:spi2=on" shown in the screenshot below, and save the file. To use the SPI0 bus, uncomment the "intf:spi0=on" line.

Enabling SPI

Step 5: Next, reboot the Tinker Board:

sudo reboot

When your Tinker Board has rebooted, you will now have SPI support.

Installing py-spidev

To use the AB Electronics UK python library with the Asus Tinker Board, you will need to install the py-spidev package.  

You can download the latest py-spidev and the setup python script from GitHub using the git command.

git clone https://github.com/doceme/py-spidev.git

Once downloaded, install py-spidev by running setup.py

cd py-spidev

For Python 2, use:

sudo python setup.py install

For Python 3, use:

sudo python3 setup.py install

py-spidev should now be available to use on your Tinker Board.


Was this article helpful? Yes No

Please tell us how we can improve this article:

Submit
Created 07/11/2022 | Last Updated: 25/10/2023

Related Expansion Boards

Order a ADC-DAC Pi Zero Photo of ADC-DAC Pi Zero
ADC-DAC Pi Zero

2 Channel ADC and 2 Channel DAC for the Raspberry Pi

£14.99 Ex VAT: £12.49
Add to Cart
Order a Expander Pi Photo of Expander Pi
Expander Pi

Analogue, Digital and RTC Expansion Interface for the Raspberry Pi

£27.59 Ex VAT: £22.99
Add to Cart

Related Articles

Asus Tinker Board Introduction
Getting started with the Tinker Board
I2C and SMBus on the Tinker Board
Configuring I2C and SMBus with Python on the Asus Tinker Board
SPI on the Tinker Board
Configuring the SPI bus on the Asus Tinker Board
OWFS with I2C support on the Asus Tinker Board
Using the 1 Wire File System with the 1 Wire Pi Plus and 1 Wire Pi Zero