Charles Bell
Warsaw, VA, USA
ISBN 978-1-4842-8134-5 e-ISBN 978-1-4842-8135-2
https://doi.org/10.1007/978-1-4842-8135-2
Charles Bell 2022
This work is subject to copyright. All rights are solely and exclusively licensed 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.
This Apress imprint is published by the registered company APress Media, LLC, part of Springer Nature.
The registered company address is: 1 New York Plaza, New York, NY 10004, U.S.A.
Introduction
The Raspberry Pi is the most popular single-board computer platform available. The boards are inexpensive, run the latest fully featured operating systems, and are backed by a growing ecosystem of developers, engineers, enthusiasts, and hobbyists. But raspberrypi.org wasnt done there. Now, we have a Raspberry Pi microcontroller called the Raspberry Pi Pico.
The Raspberry Pi Pico, with a very low cost, small form factor, and system-on-the-chip technology, is enabling many more people to learn, experience, and complete projects that would previously have required special (and expensive) hardware or having to learn a complex programming language MicroPython. Built on the parent language, Python, MicroPython provides all of the ease of programming and hardware access in Python with a special interpreter built-in that allows the Pico to boot and execute MicroPython code. Nice.
This book presents a beginners guide to MicroPython and the Raspberry Pi Pico. I cover topics including a tour of the Pico and related hardware, a tutorial on MicroPython programming, what types of sensors exist, how they communicate their values (observations or events), how they can be used in your MicroPython projects, and how to build your own Internet of Things (IoT) projects.
Who This Book Is For
I have written this book with a wide variety of readers in mind. It is intended for anyone who wants to get started building their IoT projects without learning a complicated programming language or those who want to learn how to use components, devices, and sensors with a Raspberry Pi Pico.
Whether you have already been working with IoT projects, or maybe have taken an introductory electronics course, or even have read a good Apress book on the Raspberry Pi, you will get a lot out of this book. Best of all, if you ever wanted to build your own IoT solutions, this book is just what you need!
Most importantly, I wrote this book to meet my own needs. Although there are some excellent books on the Raspberry Pi, sensors, IoT, and MicroPython, I could not find a single reference that showed how to put all of these together.
About the Chapters
There are fourteen chapters, six of which include projects that demonstrate and teach key concepts of building IoT projects. There are also chapters that introduce MicroPython, present an overview of the hardware, and teach you how to program in MicroPython, and theres also an introduction to electronics for beginners.
The project chapters are split into two groups, those projects that require discrete components to form simple IoT solutions and those that use the Grove component system to utilize Grove modules to build more sophisticated IoT projects without soldering.
Depending on your skill level with the chapter topic, you may find some of the projects easier to complete than others. It is my hope that you find the projects challenging and enlightening (but, more importantly, informative) so that you can complete your own projects. The following presents an overview of each chapter.
Chapter Introducing the Raspberry Pi Pico
In this chapter, you will learn what makes the Pico different from the Raspberry Pi boards, what a microcontroller is, and a demonstration of how easy it is to work with the Raspberry Pi Pico.
Chapter Introducing MicroPython
You will learn more about MicroPython including an overview of how to get started. The examples in this chapter are intended to give you a taste of what you can do rather than a detailed tutorial. That said, I encourage you to attempt the examples for practice. We will see a detailed tutorial for programming MicroPython in Chapter .
Chapter How to Program in MicroPython
In this chapter, you will learn some of the basic concepts of Python programming. We begin with the building blocks of the language such as variables, modules, and basic statements and then move into the more complex concepts of flow control and data structures. While the material may seem to come at you in a rush, this tutorial on Python covers only the most fundamental knowledge of the language and how to use it on your PC and Pico. It is intended to get you started writing Python applications quickly.
If you know the basics of Python programming, feel free to skim through this chapter. However, I recommend working through the example projects at the end of the chapter, especially if youve not written many Python applications.
Chapter Low-Level Hardware Support
The chapter begins with a more detailed look at the GPIO header and pins. In this chapter, you will learn the MicroPython libraries available for you to use in your projects and take a brief look at the low-level hardware support in MicroPython for the Pico. Finally, you will also revisit working with breakout boards to demonstrate some of the libraries and hardware protocols and techniques discussed in previous chapters.
Chapter Electronics for Beginners
In this chapter, you will see an overview of electronics commonly found in electronics projects. I include an overview of some of the basics, descriptions of common components, and an introduction to sensors. If you are new to electronics, this chapter will give you the extra boost you need to understand the components used in the projects in this book.