Chapter 18. Arduino and Raspberry Pi

18.0 Introduction

Although a Raspberry Pi is ideal for projects that need a network connection or a graphical user interface (GUI), the low-power general-purpose input/output (GPIO) and lack of any analog inputs puts it at a disadvantage to microcontroller boards such as the Arduino (Figure 18-1). Fortunately, it is possible to have the best of both worlds by connecting an Arduino to a Raspberry Pi and allowing the Arduino to interface with external electronics.

Arduino boards are superficially a little like a Raspberry Pi in that they are small and essentially are computers. However, Arduino boards are very different from the Raspberry Pi in a number of respects:

  • They do not have any interface to keyboard, mouse, or screen.

  • They have just 2 KB of RAM and 32 KB of flash memory for storing programs.

  • Their processor runs at just 16 MHz, compared with the Raspberry Pi 4’s 1.2 GHz.

This might lead you to wonder why you would use such an apparently feeble board rather than the Raspberry Pi directly.

The answer is that Arduino boards, the most common being the Arduino Uno, are better than the Raspberry Pi at interfacing with external electronics in several ways. For example, Arduino boards have the following features:

  • Fourteen digital inputs/outputs (I/Os), like the Raspberry Pi’s GPIO pins, but each pin can provide up to 40 mA, compared with the original Raspberry Pi’s 3 mA. This enables them to power more devices without the need for ...

Get Raspberry Pi Cookbook, 3rd Edition now with the O’Reilly learning platform.

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