Joseph Coburn
Build Your Own Car Dashboard with a Raspberry Pi
Practical Projects to Build Your Own Smart Car
1st ed.
Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the books product page, located at www.apress.com/978-1-4842-6079-1 . For more detailed information, please visit http://www.apress.com/source-code .
ISBN 978-1-4842-6079-1 e-ISBN 978-1-4842-6080-7
https://doi.org/10.1007/978-1-4842-6080-7
Apress standard
Joseph Coburn 2020
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, expressed or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
Id like to dedicate this entire book to the Raspberry Pi Foundation and the Pallets team. Without the Pi Foundation, there would be no Raspberry Pi at all, and their continued hard work to ensure that computer science is not forgotten in UK schools is something we should all strive to emulate. The Pallets team developed Flask, which is the Python framework upon which this whole book is based. Not only that, but Pallets developed many more incredibly useful Python packages, including Flask-SQLAlchemy, Click, ItsDangerous, and more. These free tools make it easy to spin up an entire Python application, and the team works tirelessly to maintain their projects to a very high standard.
Preface
Back in July of 2018 I wrote an article for MakeUseOf titled How to Add Smart Features to Your Old Car with These 10 DIY Projects. It was a fairly standard article for us at the time; a list of ten cool car projects using the Raspberry Pi and links to the tutorials and YouTube videos a fairly normal article of 1000 words or thereabouts. I dont remember anything special about this article, and my editor requested no changes at the time of submission which was great to hear. Id written several Pi articles at the time, along with several Python tutorials, but my main focus was on product reviews. At that time, Id just started a partnership with BenQ, and published several fun reviews on their 4K projectors and LCD gaming monitors.
Toward the end of June 2019, Aaron Black (senior editor at Apress) reached out to me regarding the article and enquired as to my interest in writing a book on the Raspberry Pi. Up until that point, I hadnt, but I remember thinking is that all it takes to kick off the process? I followed up on Aarons email, and after some correspondence and a pitch, I signed the contract to deliver this book in nine months. I certainly learned a lot writing this book, and its my hope that you will learn a lot by reading it.
While I had a clear structure of the book layout and managed to write the first 12,000 words within a week in August, it was certainly a huge effort that took many writing sessions, head-scratching coding sessions, and self-editing sessions locked away in my office. You sometimes wonder if its worth it at all, but having finished the book now as I write this preface, I can say unequivocally yes.
With several hundred articles under my belt with both MakeUseOf and Blocks Decoded publications, I was well practiced in juggling multiple jobs, pitches, authors, and editors, yet a minimum of 55,000 words seemed far more achievable in theory. In practice, it felt like the final 10% took 90% more effort than the first 90%. It seems the software development aphorism the ninety-ninety rule holds true for books just as much as software development. The first 90 percent of the code accounts for the first 90 percent of the development time. The remaining 10 percent of the code accounts for the other 90 percent of the development time Tom Cargill.
Introduction
The modern computer is a revolutionary device. In less than 100 years, society has changed, with computers running almost every aspect of our lives. The mobile phone is a futuristic science fictionlike gadget, with instant access to almost all the information ever created. We live in an unparalleled age of technology, one in which you can book a train, video-chat with friends, or earn money from the comfort of your own home.
In 1957, computers were the size of a bus, with each component requiring a team of people and a crane to unload. Now 63 years later, the Raspberry Pi can fit into your pocket and costs less than a takeaway. In November 2015, the Raspberry Pi Zero launched for a price of $5, and a promotional campaign saw it attached to the front of a magazine.
Few could have predicted the enduring popularity of the Raspberry Pi. With over 25 million units sold and no end in sight, its safe to say that the humble Pi has become legendary. Its low barrier to entry helped spawn a new industry. Now in its fifth generation, the Pi has been to the International Space Station in low Earth orbit. Pis can control home lighting, 3D printers, drones, security systems, arcade machines, and many more projects.
This book will teach you how to use the Raspberry Pi and the Python programming language through a practical car-based project. Not only will you learn how to build your own hardware connected to the Pi, but youll learn how to write software and the industry-standard best practices which keep your software running smoothly. These will keep you safe as a software developer. This book may not be like others you read. I want you to question everything. Its hoped you will learn how the circuits work, and why the code looks like it does, instead of copying the code and hoping for the best. By doing this, youll gain a solid foundation in both the Raspberry Pi and software development.
Throughout this book, I encourage you to hand-type every line of code. It will be tedious, and the temptation to grab the code from GitHub and paste it into your work will always be present. I promise you that by really understanding every line, and each and every word by reading, understanding, and typing it yourself, youll become a better programmer. Im a big fan of simple code and hopefully the projects contained in this book are manageable. Each project starts small and then builds in complexity as your confidence grows each chapter expanding on concepts learned in the previous chapter.