Preface to the Third Edition

Launched in 2011, the Raspberry Pi has found a role both as a very low-cost Linux-based computer and as a platform for embedded computing. It has proven popular with educators and hobbyists alike.

As of this writing, more than 20 million Raspberry Pis have been sold. The Raspberry Pi 4 with an option of 4 GB of performance makes the Raspberry Pi more than powerful enough to use as a replacement for a desktop computer. The availability of open source software for internet browsing, email, office suites, and photo editing is set to make the Raspberry Pi even more popular.

Even the latest Raspberry Pi 4 still includes the general-purpose input/output (GPIO) pins that allow the hobbyist to add their own electronic contraptions to the Raspberry Pi.

This edition has been thoroughly updated to encompass the new models of Raspberry Pi, as well as the many changes and improvements to its Raspbian operating system. There are also new chapters on sound and home automation.

This book is designed so that you can read it linearly, as you would a regular book, or access recipes at random. You can search the table of contents or index for the recipe that you want and then jump directly to it. If the recipe requires you to know about other things, it will refer you to other recipes, rather like a cookbook might refer you to base sauces before showing you how to cook something fancier.

The world of Raspberry Pi moves quickly. With a large, active community, new interface boards and software libraries are being developed all the time. In addition to examples that use specific interface boards or software, the book also covers basic principles so that you can have a better understanding of how to use new technologies that come along as the Raspberry Pi ecosystem develops.

As you would expect, a large body of code (mostly Python programs) accompanies the book. These programs are all open source and available on GitHub. For most of the software-based recipes, all you need is a Raspberry Pi. I recommend a Raspberry Pi 3 or 4 model B. When it comes to recipes that involve making your own hardware to interface with the Raspberry Pi, I have tried to make good use of ready-made modules as well as solderless breadboard and jumper wires to avoid the need for soldering.

If you want to make breadboard-based projects more durable, I suggest using prototyping boards with the same layout as a half-size breadboard, such as those sold by Adafruit and elsewhere, so that the design can easily be transferred to a soldered solution.

Using This Book

The cookbook style of this book means that it is not a book that you must read in order from front to back. The book is made up of individual recipes grouped into chapters. Where a recipe needs you to have prior knowledge of some other topic, the recipe will send you off to another recipe for that topic.

You will probably find that you jump around from recipe to recipe as you try to get your Raspberry Pi project to do what you want.

I have mapped out a few paths through the book that I think would be useful to different types of readers:

Complete Raspberry Pi beginner
Read most of Chapters 1, 2, and 3—in particular, start with Recipe 1.1Recipe 1.2Recipe 1.4, and Recipe 1.6—and then wander at will.
Python learner
If you want to use your Raspberry Pi to learn how to program in Python, work your way through Chapters 4 to 7. You will probably find that you need to jump off to various recipes in earlier chapters.
Electronics hobbyist
If you don’t already have them, you will need to pick up some Python skills by working through Chapters 4 to 7, and then work through Chapter 8 before picking out interesting recipes in the later chapters to start making yourself some interesting Raspberry Pi electronics projects.

Conventions Used in This Book

The following typographical conventions are used in this book:

Italic

Indicates new terms, URLs, email addresses, filenames, and file extensions.

Constant width

Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.

Constant width bold

Shows commands or other text that should be typed literally by the user.

Constant width italic

Shows text that should be replaced with user-supplied values or by values determined by context.

Tip

This icon signifies a tip, suggestion, or general note.

Warning

This icon indicates a warning or caution.

Note

This icon points you to the related video for that section.

Using Code Examples

Supplemental material (code examples, etc.) is available for download at https://github.com/simonmonk/raspberrypi_cookbook_ed3.

This book is here to help you get your job done. In general, if example code is offered with this book, you may use it in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.

We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Raspberry Pi Cookbook, Third Edition, by Simon Monk (O’Reilly). Copyright 2020 Simon Monk, 978-1-492-04322-5.”

If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at .

O’Reilly Online Learning

Note

For more than 40 years, O’Reilly Media has provided technology and business training, knowledge, and insight to help companies succeed.

Our unique network of experts and innovators share their knowledge and expertise through books, articles, conferences, and our online learning platform. O’Reilly’s online learning platform gives you on-demand access to live training courses, in-depth learning paths, interactive coding environments, and a vast collection of text and video from O’Reilly and 200+ other publishers. For more information, please visit http://oreilly.com.

How to Contact Us

Please address comments and questions concerning this book to the publisher:

  • O’Reilly Media, Inc.
  • 1005 Gravenstein Highway North
  • Sebastopol, CA 95472
  • 800-998-9938 (in the United States or Canada)
  • 707-829-0515 (international or local)
  • 707-829-0104 (fax)

We have a web page for this book where we list errata, examples, and any additional information. You can access this page at https://oreil.ly/raspberry-pi-cookbook-3e.

Email to comment or ask technical questions about this book.

For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com.

Find us on Facebook: http://facebook.com/oreilly

Follow us on Twitter: http://twitter.com/oreillymedia

Watch us on YouTube: http://www.youtube.com/oreillymedia

Acknowledgments

As always, I thank my wife, Linda, for her patience and support.

I also thank the technical reviewers, Duncan Amos and Ian Huntley, for their excellent help and suggestions that have without a doubt contributed greatly to this book.

Thanks also to Jeff Bleiel and all the O’Reilly team and, of course, Bob Russell of Octal Publishing for his diligent copyediting.

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.