Chapter 8Interfacing to the Raspberry Pi Buses

This chapter describes bus communication in detail, explaining and comparing the different bus types that are available on the Raspberry Pi. It describes how you can configure them for use, and how you can communicate with and control I2C, SPI, and UART devices, using both Linux tools and custom-developed C/C++ code. Practical examples are provided using different low-cost bus devices, such as a real-time clock, an accelerometer, a serial shift register with a seven-segment display, a USB-to-TTL 3.3 V cable, and a GPS receiver. After reading this chapter, you should have the skills necessary to begin interfacing almost any type of bus device to the Raspberry Pi.

Equipment Required for This Chapter:
  • Raspberry Pi (ideally an RPi 2/3)
  • A real-time clock on a breakout board (e.g., the DS3231)
  • ADXL345 accelerometer on an I2C/SPI breakout board
  • 74HC595 shift register, seven-segment display, and resistors
  • A USB-to-TTL 3.3 V cable (see Chapter 1 and Chapter 2)
  • A low-cost UART GPS receiver (e.g., the GY-GPS6MV2)

Further details on this equipment and chapter are available at www.exploringrpi.com/chapter8.

Introduction to Bus Communication

In Chapter 6, the use of general-purpose input/outputs (GPIOs) is discussed in detail, which makes it clear how you can connect the RPi to standalone components, including one-wire sensors that have custom communications protocols. This chapter examines more complex communications that can be performed ...

Get Exploring Raspberry Pi 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.