In this guide, we will be showing you how to enable SPI on Raspberry Pi. SPI is a synchronous serial interface for devices.
SPI, which stands for a serial peripheral interface, is a synchronous serial communication interface that allows one device to communicate data to another.
The SPI protocol is similar to the I2C protocol in that both are intended to enable devices to interact with one another.
The benefits of using SPI in a circuit are its communication and speed capabilities. The increased speed and communication are mostly attributable to the use of two different channels for data in and data out.
SPI can send data significantly faster than the I2C protocol is capable of, but it is more complicated to wire together.
In our RFID tutorial, we use an SPI connection to communicate with the RC522 chip on our Raspberry Pi.
The Raspberry Pi has two accessible channels, even though it is only equipped with one SPI bus.
To enable and test SPI on Raspberry Pi, we used the equipment shown below.
Enabling support for SPI on Raspberry Pi
The Raspberry Pi's kernel by default disables support for the SPI bus interface.
Using the raspi-config tool, we'll be showing you how to enable SPI in this part.
1- To begin, we need to first make sure that we are using the most recent version of
We will need to run the following two commands to update it and all other packages:
sudo apt update
sudo apt full-upgrade
2- We may now start the config tool after the Pi has been upgraded.
We need to run the following command to load it.
You need to navigate with the “ARROW” keys and choose using the “ENTER” key in this tool.
3- You need to access the
5 Interfacing Options menu inside this tool.
We will be able to configure interfaces like SPI inside this menu.
4- You need to select
P4 SPI next.
The screen that will allow us to enable or disable the SPI bus will take us there.
5- Press the “ENTER” key after selecting
<Yes> when asked whether you wish to enable the SPI interface.
6- The SPI interface is now successfully enabled.
Press the “ESC” key to exit now.
7- For SPI to be usable, we will need to restart the Raspberry Pi.
These changes are only loaded during the Raspberry Pi’s reboot sequence.
When prompted to reboot, highlight and activate
Testing Enabled SPI on Raspberry Pi
We may check to make sure the SPI interface is available now that it has been enabled.
1- To check whether SPI is enabled, use the ls command to list the available interfaces.
To list all of the current files in the
/dev/spidev directory, use the following command:
ls -l /dev/spidev*
From this command, you should get the following result:
pi@raspberrypi:~ $ ls -l /dev/spidev*
crw-rw---- 1 root spi 153, 0 Jul 23 12:43 /dev/spidev0.0
crw-rw---- 1 root spi 153, 1 Jul 23 12:43 /dev/spidev0.1
You can see the two available channels through our SPI connection: channel 0 and channel 1.
At this point in the guide, you should now have the SPI enabled on Raspberry Pi.