User Guide
Table Of Contents
173
11. Press Ctrl + X.
12. Type the following command and then press Enter:
sudo shutdown -r now
When the Pi restarts, the SPI modules load automatically.
Using SPI from Python 3
To use SPI from Python, you need to install the python3-dev
libraries, and a module for Python that makes the SPI devices
accessible.
1. On the Application Launcher, click LXTerminal.
2. Type the following command and then press Enter:
sudo apt-get install python3-dev
3. When the installation is complete, type the
following command and then press Enter:
git clone git://github.com/rpodgornypy-spidev
4. Type the following command and then press Enter:
cd py-spidev
5. Type the following command and then press Enter:
sudo python3 setup.py install
When connecting the Pi to SPI devices, the GPIO pin MOSI
(master output, slave input) connects to the SI (slave input) pin
on the external device. Similarly, the GPIO pin MISO (master
input, slave output) connects to the SO (slave output) pin.
Figure 10 shows how to connect the Raspberry Pi to a 64 Kb SPI
SRAM chip from Microchip Technology, Inc. The 23K640 is a 3.3
V, 8-pin device that you can use to store a byte in each of its
8192 slots (or “addresses”). This means that the chip has 8 KB
(64 Kb) of volatile storage.
Volatile memory chips lose their contents when you disconnect
them from the power. Non-volatile memory chips, such as “flash”
memory technologies, retain their contents.