Raspberry Pi and MQTT Essentials
A complete guide to helping you build innovative full-scale prototype projects using Raspberry Pi and MQTT protocol
Dhairya Parikh
BIRMINGHAMMUMBAI
Raspberry Pi and MQTT Essentials
Copyright 2022 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Group Product Manager: Rahul Nair
Publishing Product Manager: Meeta Rajani
Senior Content Development Editor: Sayali Pingale
Technical Editor: Rajat Sharma
Copy Editor: Safis Editing
Project Manager: Neil Dmello
Proofreader: Safis Editing
Indexer: Subalakshmi Govindhan
Production Designer: Shyam Sundar Korumilli
Marketing Coordinator: Nimisha Dua
Senior Marketing Coordinator: Sanjana Gupta
First published: August 2022
Production reference: 0240822
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
978-1-80324-448-8
www.packt.com
To my parents, Bhumika and Atit, for their sacrifices and constant encouragement.
Contributors
About the author
Dhairya Parikh currently works as a data engineer at Accenture, where he builds efficient data products to help their clients get the most out of their data. He completed his undergraduate studies in electronics engineering at BVM Engineering College, Anand. He is a seasoned project developer with several award-winning projects under his belt. His most recent literary works include several articles written for the Circuit Cellar magazine. Most of his articles and projects are based on IoT and machine learning. He is an open source enthusiast with an interest in building projects that make a positive impact on peoples lives using new development hardware and writing about them in his spare time.
I would like to thank my parents and family for their constant support and encouragement throughout this project.
I would also like to thank Neil Dmello, Shazeen Iqbal, Preet Ahuja, Rafiaa Khan, and the entire Packt team for their guidance throughout this project, and Asim Zulfiqar and John Witts for their technical insights! Finally, I would like to thank Yashashree Hardikar for all the initial support.
About the reviewer
Asim Zulfiqar is a blogger and tech content creator who has been writing tutorials on embedded systems and IoT, specifically on MQTT, on his blog and YouTube channel, High Voltages. He also provides IoT and embedded freelance services to companies through this channel.
He completed his bachelors degree in electronic engineering at Sir Syed University of Engineering and Technology, Pakistan. After that, he completed his Erasmus Mundus joint masters degree program in Photonics Integrated Circuits, Sensors, and Networks at Scuola Superiore SantAnna (Italy), Aston University (UK), and Osaka University (Japan).
Reviewing a book is more exciting than I thought, and I have enjoyed reviewing this book. None of this would have been possible without my family, friends, teachers, and all the open-source communities that helped me gain enough knowledge to do so. I would also like to thank the author of this book, Dhairya, who helped me learn some new concepts, and Packt, for providing me this opportunity.
Preface
The future of IoT has the potential to be limitless. By 2025, it is estimated that there will be more than 21 billion IoT devices. So, wouldnt it be great if you could add these to your known technological stacks? But where to start? Of course, with the basics.
First, we will learn about the most popular hardware used for IoT prototyping, the Raspberry Pi. Then, we will learn what MQTT, one of the most used communication protocols for communicating between devices, is. We will then explore why these are the most suitable options to get started, their advantages, and how they are currently being used in the industry. Then, you will see how to use them together by setting up your very own MQTT Server on the Raspberry Pi and understanding how it works. We will get into the details of MQTT and learn more about the clients or devices we will connect to our server. In particular, we will cover two very popular IoT development boards among project developers: ESP8266 and ESP32. You will also learn how to build interactive dashboards on your Pi and control or monitor your client devices. You will build the dashboards using another popular software Node-RED.