Chapter 16. Arduino and Raspberry Pi

16.0 Introduction

While a Raspberry Pi is ideal for projects that need a network connection or a graphical user interface, the low-power GPIO outputs and lack of any analog inputs puts it at a disadvantage to microcontroller boards, such as the Arduino (Figure 16-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 a computer. 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 for storing programs.

  • Their processor runs at just 16 MHz compared with the Raspberry Pi’s 700 MHz.

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:

  • 14 digital inputs/outputs, 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 extra electronics.

  • 6 analog inputs. This makes connecting analog sensors much ...

Get Raspberry Pi Cookbook, 2nd Edition 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.