Enabling SPI on Raspberry Pi

The Serial Peripheral Interface bus (SPI) is a synchronous serial communication interface specification used for short distance communication, primarily in embedded systems. The interface was developed by Motorola.

SPI devices communicate in full duplex mode using a master-slave architecture with a single master. The master device originates the frame for reading and writing. Multiple slave devices are supported through selection with individual slave select (SS) lines.

Read more details on Wikipedia

The SPI bus specifies five logic signals:

SCLK: Serial Clock (output from master).
MOSI: Master Out Slave In (data output from master).
MISO: Master In Slave Out (data output from slave).
SDIO: Serial Data I/O (bidirectional I/O)
SS: Slave Select (often active low, output from master).

I am using RaspberryPi Model B. First i turned on the Pi, i used NOOBS Raspbian operating system (https://www.raspberrypi.org/downloads/noobs/). I don’t have a HDMI display, so i connected it to network found out the ip of the Pi and did ssh using the following command

ssh pi@ip-address

The default password for ssh is “raspberry” if you are using NOOBS debian distro.

The SPI is not enabled by default. To enable SPI issue the following command

sudo raspi-config

Then Select Interfacing Options

Select SPI

It will ask for Enable or Disable, Enable SPI

Finish the config and reboot

After reboot you can see two spidev’s by issuing the command

ls /dev/spi*

This mean SPI is enabled on your Raspberry Pi