Basics of SPI and setting up an SPI module

The SPI, or Serial Peripheral Interface, is similar to the I2C bus, but has a few advantages for a few more wires. Generally, you'd choose I2C or SPI based on the peripheral you are trying to talk to and what protocol it supports. For this recipe, we will look at configuring SPI for upcoming recipes.

Getting ready

Just like setting up I2C in the previous recipe, the easiest way to get going is with raspi-config. Run with sudo, and select Interfacing Options. Select P4 to enable SPI, and reboot.

Getting ready

How to do it...

Once you've enabled SPI and rebooted, you should find your bus on the device list:

Working with ...

Get Raspberry Pi Zero Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.