Chapter 11Real-Time Interfacing Using the Arduino

A key strength of Linux on embedded systems is the vast amount of software and device drivers that is freely available. Unfortunately, the overhead of running Linux is problematic for the performance of high-speed interfacing tasks—for example, generating or sampling bit patterns on general-purpose inputs/outputs (GPIOs) at high speeds. One solution to this problem is to use dedicated real-time slave processors and to communicate with them using high-level protocols. There are many suitable slave processors available, but this chapter is focused on just one platform: the Arduino. This chapter describes how the Raspberry Pi (RPi) can interface effectively to the Arduino using UART serial, I2C, and Serial Peripheral Interface (SPI) communication. Examples are provided of the Arduino in use as an input/output extender and as a dedicated high-speed slave processor.

Equipment Required for This Chapter:
  • Raspberry Pi (any model)
  • An Arduino Uno or equivalent1 (with a logic-level translator) and/or an Arduino Pro Mini with 3.3V or 5V logic levels
  • Sensors: TMP36 analog temperature sensor and an HC-SR04 distance sensor

Further details on this chapter are available at

The Arduino

The Arduino ( is a popular, low-cost, and powerful microcontroller that can be used as a very capable companion controller for the RPi. The Arduino platform was designed as an introductory platform for embedded ...

Get Exploring Raspberry Pi now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.