Portable Python Projects
Run Your Home on a Raspberry Pi
by Mike Riley
Version: P1.0 (February 2022)
Copyright 2022 The Pragmatic Programmers, LLC. This book is licensed to the individual who purchased it. We don't copy-protect it because that would limit your ability to use it for your own purposes. Please don't break this trustyou can use this across all of your devices but please do not share this copy with other members of your team, with friends, or via file sharing services. Thanks.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and The Pragmatic Programmers, LLC was aware of a trademark claim, the designations have been printed in initial capital letters or in all capitals. The Pragmatic Starter Kit, The Pragmatic Programmer, Pragmatic Programming, Pragmatic Bookshelf and the linking g device are trademarks of The Pragmatic Programmers, LLC.
Every precaution was taken in the preparation of this book. However, the publisher assumes no responsibility for errors or omissions, or for damages that may result from the use of information (including program listings) contained herein.
About the Pragmatic Bookshelf
The Pragmatic Bookshelf is an agile publishing company. Were here because we want to improve the lives of developers. We do this by creating timely, practical titles, written by programmers for programmers.
Our Pragmatic courses, workshops, and other products can help you and your team create better software and have more fun. For more information, as well as the latest Pragmatic titles, please visit us at http://pragprog.com.
Our ebooks do not contain any Digital Restrictions Management, and have always been DRM-free. We pioneered the beta book concept, where you can purchase and read a book while its still being written, and provide feedback to the author to help make a better book for everyone. Free resources for all purchasers include source code downloads (if applicable), errata and discussion forums, all available on the book's home page at pragprog.com. Were here to make your life easier.
New Book Announcements
Want to keep up on our latest titles and announcements, and occasional special offers? Just create an account on pragprog.com (an email address and a password is all it takes) and select the checkbox to receive newsletters. You can also follow us on twitter as @pragprog.
About Ebook Formats
If you buy directly from pragprog.com, you get ebooks in all available formats for one price. You can synch your ebooks amongst all your devices (including iPhone/iPad, Android, laptops, etc.) via Dropbox. You get free updates for the life of the edition. And, of course, you can always come back and re-download your books when needed. Ebooks bought from the Amazon Kindle store are subject to Amazon's polices. Limitations in Amazon's file format may cause ebooks to display differently on different devices. For more information, please see our FAQ at pragprog.com/#about-ebooks. To learn more about this book and access the free resources, go to https://pragprog.com/book/mrpython, the book's homepage.
Thanks for your continued support,
Andy Hunt
The Pragmatic Programmers
The team that produced this book includes: Dave Rankin (CEO) Janet Furlow (COO) Tammy Coron (Managing Editor) Jacquelyn Carter (Development Editor) L. Sakhi MacMillan (Copy Editor) Potomac Indexing, LLC (Indexing) Gilson Graphics (Layout) Andy Hunt and Dave Thomas (Founders)
For customer support, please contact .
For international rights, please contact .
Table of Contents
Copyright 2022, The Pragmatic Bookshelf.
Early Praise for Portable Python Projects
This book covers many aspects of computer technology with a wonderful building-block approach, teaching the reader through every project. From the simple first project to the more complex, the builder is skillfully taught about Raspberry Pis and their hardware, Python and its libraries, automation, and most importantly, designing something useful from all these parts. By the end of the book, the reader is equipped to continue exploring in many new directions. I love this book.
Michael Bengtson |
Engineering Manager, Sprocks |
I would recommend this book to most of the experienced software developers I know. It is a perfect read for long evenings in autumn when you have time to learn something new. This book can help you to improve your home, and it can inspire tons of new ideas youd never thought of before reading it.
Maik Schmidt |
Software Developer and Writer |
Portable Python Projects takes a practical approach to learning Raspberry Pi Python through complete implementations and concise meaningful explanations. I learned a number of useful Python strategies and a great deal about the Raspberry Pi platform. Python and the Pi are a perfect combination because together they are a simple, effective, and powerful platform. I highly recommend Portable Python Projects to both beginners and long-time enthusiasts.
John Cairns |
Staff Engineer, Blocknative |
With this book Mike Riley opens the door for anyone who is curious about what can be done with a microcontroller and a little Python code. Newbies will find great step-by-step instruction to complete some innovative projects, and veterans will find inspiration to take take things to a new level.
Sven Davies |
IT Director, AC Americas |
Mikes insightful approach to practical Pi projects will allow new as well as experienced people to quickly build innovative solutions.
Jim Szubryt |
Senior Delivery Principal, Slalom |
Acknowledgments
Writing a book is like having a child, in that only those who have one truly know what the experience is like. This is my fourth book published by Pragmatic Bookshelf, and like those before, it could not have been possible without the tremendous support and consistent encouragement and guidance of the editor and publishers. Jackie Carter has been the development editor on all my Pragmatic titles, and she once again has shown with this work why she is one of Pragmatics best editors. Thank you Jackie for everything!
I would also like to thank those who provided invaluable feedback on my earlier drafts to bring more clarity and specificity to the projects. Mike Bengtson, John Cairns, Sven Davies, Jim Szubryt, John Winans, and fellow Pragmatic Bookshelf author Maik Schmidt were especially instrumental in guiding the book to the final form you are about to read. You guys are amazing!
Finally, it should go without saying that without Andy Hunt and Dave Thomas, the progenitors of the Pragmatic Bookshelf, this book would not exist. They are two of the smartest technologists and book authors in the tech industry and have built a trusted platform under the expert guidance of CEO Dave Rankin that is among the most respected tech book publishers in the industry. It is an honor to be associated with such a top-tier group of outstanding individuals.
Copyright 2022, The Pragmatic Bookshelf.
Introduction
Welcome to the Pi. The journey ahead will guide you through the process of obtaining and configuring the right hardware and software to create unique and interesting applications.