Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Hands-On Internet of Things with MQTT

You're reading from  Hands-On Internet of Things with MQTT

Product type Book
Published in Oct 2019
Publisher Packt
ISBN-13 9781789341782
Pages 350 pages
Edition 1st Edition
Languages
Author (1):
Tim Pulver Tim Pulver
Profile icon Tim Pulver

Table of Contents (16) Chapters

Title Page
Copyright and Credits About Packt Contributors Preface The Internet of Things in a Nutshell Basic Architecture of an IoT Prototype Getting Started with MQTT Setting Up a Lab Environment Building Your Own Automatic Pet Food Dispenser Building a Smart E-Ink To-Do List Building a Smart Productivity Cube, Part 1 Building a Smart Productivity Cube, Part 2 Presenting Your Own Prototype Assessments Other Books You May Enjoy

Preface

First and foremost, I would like to thank you for purchasing this book and going on a journey of Internet of Things (IoT) prototyping with me.

In my teenage years, before the first Arduino was invented, I had a friend who was knowledgeable about electronics. He was considered a nerd and really knew what he was doing. Looking at his soldered prototypes, which consisted of a lot of cables, chips, and other electronic components that I didn't know about at the time, I was fascinated. I did not have any idea where to start building electronic prototypes myself; it seemed like such a huge field that there was no way for me to find an entry point. At that time, it was very far from my imagination that I would later be able to create prototypes myself, and, even more so, that I would write a book about the topic one day.

A lot of things have changed since then. One of those things is the creation of Arduino and Processing, which made it possible to learn programming and hardware prototyping without any prior knowledge. The field opened up to designers, artists, and makers. It is now easier than ever to get started with hardware prototyping and bring your own ideas into reality.

While building physical projects alone creates a lot of possibilities, being able to use internet-connected devices and connect them to each other and the rest of the web opens up a whole new world of possibilities.

There are many ways to connect two internet-connected devices and exchange information between them. One of these possibilities, which in my opinion is the easiest and most open, is MQTT. Being open in this sense means that third-party developers can create apps and libraries for it. There is a vast ecosystem of tools, libraries, and apps that all speak the same language of MQTT.

Building internet-connected devices has never been easier, and using MQTT to build them makes it possible to prototype even faster, while also having access to all these third-party tools.

When I was initially looking into possibilities for how to let my prototypes talk to each other over the internet, MQTT stood out, but I could not find much information about it. It seemed like a niche topic and I could not understand why.

If you want to create your own inventions, experimental prototypes, and custom devices, getting to know MQTT is a great decision, and I hope that, by reading this book, you will benefit from a smooth entry into the world of IoT prototyping using MQTT.

Welcome on this journey!

Who this book is for

This book is ideal for readers who want to start creating internet-connected projects themselves, but only have a little bit of experience of programming and using the Arduino IDE. You do not need to have a computer science background to follow along. Simply curiosity and a basic understanding of programming in Arduino will be enough. If you understand basic programming concepts such as variables, loops, conditions, and functions, then you will have no problem following along.

Some of the chapters touch on a lot of different topics. I do not expect you to understand every single bit in detail. The goal here is to give you a general overview of related technologies and techniques, so you can dive into any of the topics after finishing the book. You can look at it as a starting point for IoT prototyping.

For an intermediate or professional programmer, the pace of the hands-on projects in this book might feel a bit slow, but there is plenty of relevant information for you in the theoretical chapters as well, including how to use MQTT.

What this book covers

Chapter 1, The Internet of Things in a Nutshell, gives you an overview of fields where IoT plays an important role. It introduces you to smart cars, the Industrial Internet of Things (IIoT), and smart homes.

Chapter 2, Basic Architecture of an IoT Prototype, introduces you to related technologies and concepts, as well as microcontroller recommendations for IoT prototyping. This chapter touches on a lot of topics and should be seen as a starting point for your own learning, after which you can dig deeper into the topics that interest you.

Chapter 3, Getting Started with MQTT, explains the concepts behind MQTT, the lightweight IoT protocol we will be using throughout the entire book. While we only use a subset of the features explained in this chapter during the hands-on projects, you can use it as a reference to go back to if you want to create more advanced MQTT projects later. Feel free to create a bookmark for this chapter, as you will hopefully re-read fragments from it.

Chapter 4, Setting Up a Lab Environment, explains how to install the software needed for the hands-on projects. It also includes a shopping list with all the necessary hardware for the projects.

Chapter 5, Building Your Own Automatic Pet Food Dispenser, is the first hands-on project in the book. It will show you, using a servo motor, how to control an automatic dispenser using MQTT, either from your computer or smartphone using one of the apps introduced in Chapter 3, Getting Started with MQTT. You can fill the dispenser with pet food, sweets, cereals, or whatever you like.

Chapter 6, Building a Smart E-Ink To-Do List, is the second hands-on project in the book. In this chapter, you will learn how to use an energy-efficient e-ink display and send text to it using MQTT. The display could, for example, be hung next to your front door to remind you to take out the trash or buy milk.

Chapter 7, Building a Smart Productivity Cube, Part 1, is the third and final hands-on project in the book. It explains how to create an orientation sensor from scratch using simple electrical components called tilt switches. The cube can then be used to record the time you spend on various activities. Because all three projects use MQTT, they can also be chained together, such that activating the smart productivity cube might show some text on the e-ink display and activate the food dispenser.

Chapter 8, Building a Smart Productivity Cube, Part 2, is the second part of building a smart productivity cube. Based on the prototype that we built together in the previous chapter, we will add MQTT connectivity and make use of third-party MQTT clients to receive and display the data coming from your prototype.

Chapter 9, Presenting Your Own Prototype, introduces technologies such as laser cutting and 3D printing to build great-looking and sturdy cases. It will give you an idea of how professional prototypes are made using Printed Circuit Board (PCB) services and software. While making a product out of your ideas probably seems far-fetched to you, I want you to explore different options and where continuing on this path might lead you.

To get the most out of this book

To get the most out of this book, you'll need to understand basic programming concepts such as variables, conditions, loops, and functions. You might have gained this knowledge by reading an Arduino book for complete beginners before that explained those concepts in detail. There are many books on getting started with Arduino for you to choose from.

If you run into any problems that you cannot solve yourself, feel free to ask for help on the book's repository on GitHub (https://github.com/PacktPublishing/Hands-on-IOT-with-MQTT) by opening an issue, and I will try to help you. To do so, you will need to create a GitHub account (if you do not already have one). 

You can find all the required pieces of software, along with instructions on how to install them, in Chapter 4, Setting up a Lab Environment. If you skip the first hands-on project in Chapter 5, Building Your Own Automatic Pet Food Dispenser, starting directly with the second or third one (in Chapters 6, Building a Smart E-Ink To-Do List, and Chapter 7, Building a Smart Productivity Cube, Part 1 and Chapter 8Building a Smart Productivity Cube, Part 2 ), please make sure to also follow the instructions on how to set up MQTT and the Wi-Fi library at the beginning of Chapter 5, Building Your Own Automatic Pet Food Dispenser.

You will get the most out of this book by reading Chapter 1, The Internet of Things in a Nutshell, to Chapter 5, Building Your Own Automatic Pet Food Dispenser, in a linear way. Chapter 6, Building a Smart E-Ink To-Do List, to Chapter 9, Presenting Your Own Prototype, can be read in any order you like.

Download the example code files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packt.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packt.com.
  2. Select the Support tab.
  3. Click on Code Downloads.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for macOS
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Hands-On-Internet-of-Things-with-MQTTIn case there is an update to the code, it will be updated on the existing GitHub repository. If you want to make sure to have the latest code you should download it from GitHub.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

Code in Action

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "So, often, it is better to rewrite delay() calls to use a custom timer instead of using the millis() function."

A block of code is set as follows:

if temperature < 5°C {
send me a reminder to use beanie and gloves
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

if (inputValue == 1) {
lastTimeOpenend = millis();
isOpen = true;
myservo.write(90);
}

Any command-line input or output is written as follows:

mosquitto_pub

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Click on Tools | Serial Monitor to open the serial monitor."

Warnings or important notes appear like this.
Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at customercare@packtpub.com.

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packt.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at copyright@packt.com with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packt.com.

lock icon The rest of the chapter is locked
You have been reading a chapter from
Hands-On Internet of Things with MQTT
Published in: Oct 2019 Publisher: Packt ISBN-13: 9781789341782
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}