Hands-On Internet of Things with MQTT
eBook - ePub

Hands-On Internet of Things with MQTT

Build connected IoT devices with Arduino and MQ Telemetry Transport (MQTT)

  1. 350 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Hands-On Internet of Things with MQTT

Build connected IoT devices with Arduino and MQ Telemetry Transport (MQTT)

Book details
Book preview
Table of contents
Citations

About This Book

Develop a variety of projects and connect them to microcontrollers and web servers using the lightweight messaging protocol MQTT

Key Features

  • Leverage the power of MQTT to build a pet food dispenser, e-ink to-do list, and a productivity cube
  • Learn about technologies like laser cutting, 3D printing, and PCB production for building robust prototypes
  • Explore practical uses cases to gain an in-depth understanding of MQTT

Book Description

MQ Telemetry Transport (MQTT) is a lightweight messaging protocol for smart devices that can be used to build exciting, highly scalable Internet of Things (IoT) projects.

This book will get you started with a quick introduction to the concepts of IoT and MQTT and explain how the latter can help you build your own internet-connected prototypes. As you advance, you'll gain insights into how microcontrollers communicate, and you'll get to grips with the different messaging protocols and techniques involved. Once you are well-versed with the essential concepts, you'll be able to put what you've learned into practice by building three projects from scratch, including an automatic pet food dispenser and a smart e-ink to-do display. You'll also discover how to present your own prototypes professionally. In addition to this, you'll learn how to use technologies from third-party web service providers, along with other rapid prototyping technologies, such as laser cutting, 3D printing, and PCB production.

By the end of this book, you'll have gained hands-on experience in using MQTT to build your own IoT prototypes.

What you will learn

  • Explore MQTT programming with Arduino
  • Discover how to make your prototypes talk to each other
  • Send MQTT messages from your smartphone to your prototypes
  • Discover how you can make websites interact with your prototypes
  • Learn about MQTT servers, libraries, and apps
  • Explore tools such as laser cutting and 3D printing in order to build robust prototype cases

Who this book is for

If you are an IoT developer or enthusiast who wants to start building IoT prototypes using MQTT, this book is for you. Basic knowledge of programming with Arduino will be useful.

Frequently asked questions

Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes, you can access Hands-On Internet of Things with MQTT by Tim Pulver in PDF and/or ePUB format, as well as other popular books in Informatique & Matériel. We have over one million books available in our catalogue for you to explore.

Information

Year
2019
ISBN
9781789345001
Edition
1
Subtopic
Matériel

Section 1: An Introduction to IoT and MQTT

This section offers a quick introduction to what the Internet of Things (IoT) is, why readers should care about it, what MQTT is, and how MQTT can help readers to build their own prototypes.
The following chapters will be covered in this section:
  • Chapter 1, The Internet of Things in a Nutshell
  • Chapter 2, Basic Architecture of an IoT Prototype
  • Chapter 3, Getting Started with MQTT

The Internet of Things in a Nutshell

Kids who grew up in the 1990s, like myself, will have noticed a lot of changes to our everyday lives over the last 30 years because of the internet and its omnipresence. Having a wireless connection wherever we go, checking emails and Facebook on our smartphones: all of this didn't exist in the 1990s. Smartphones? We had mobile phones, yes, but with a monochrome display and an antenna, and they didn't have an internet connection. The multimedia highlight was playing the game Snake, a simple 2D game with a game logic that can be programmed in a day. There was no mobile internet and no wireless LAN. When we were visiting another city and got lost, we had to go inside a store and ask for help—no Google Maps.
Nowadays, the internet is ubiquitous and people are dependent on it for their day-to-day life. Everyone has a phone in their pocket, which they can use to find any information they want in seconds. According to a study by Business Insider, on average, there will be four internet-connected devices per human by 2020.
Smart devices come in various forms and shapes and are causing disruptions in every industry, just like the internet did in the early 2000s. Companies such as Google and Samsung have been developing wearable devices, such as smartwatches and health trackers, automated robots for industrial applications, self-driving cars, smart buildings, and smart home devices, as well as early-warning systems for tsunamis or earthquakes.
In this chapter, we will explore some of the devices and technologies that are driving the internet-connected device revolution. We will have a closer look at the following topics:
  • Exploring smart homes
  • Exploring smart cars
  • Exploring industry 4.0 / the Industrial Internet of Things
  • Prototyping for the greater good
  • What is a prototype?
  • Voice control
  • Why should you invest in the IoT?

Exploring smart homes

The most prominent category of Internet of Things (IoT) devices for end consumers is smart home—connected electronic devices that are used in your flat or house. They often replace traditional electronic devices by enhancing them with an internet connection and a way to control them digitally. In most cases, they offer a smartphone app or integration with a smart home app, such as Google Home, which makes it possible, for example, to turn the device on and off from your sofa, change its settings, and check its status.
According to a study by Zion Market Research (https://www.zionmarketresearch.com/news/smart-home-market), the global smart home market is about to reach around USD 53.45 billion by 2022, with big tech companies such as Samsung and Google being at the forefront. Let's look at some examples of these smart home devices:
  • Smart fridges
  • Smart door locks
  • Smart thermostats
  • Smart scales
  • Smart lights
  • Smart pet food dispensers
These are only a few of the smart home devices available today. The potential of such smart devices to influence our lives is huge.
Let's look at an example of a smart device—a smart fridge—and see what benefits it brings over a non-smart device.
The main problems people tend to have with a regular fridge are the following:
  • Food goes to waste because you have no clear overview of expiration dates for each item.
  • You run out of a certain food because you did not keep track of your supply.
Smart fridges keep track of your groceries and their expiration dates and warn you when you might run out of your favorite food. When opening the fridge, it could also present you with recommendations for what to cook with the available ingredients.
To minimize food waste, it might detect that you have, for example, tomatoes, curry sauce, and onions that will go bad soon. It might then automatically run an online search and present you with recipes that include these ingredients for you to prepare.
If it is connected to third-party shopping providers, it might also take care of ordering food automatically for you—for example, when your milk is running low, it might order a new bottle for you, which will then either be delivered to your doorstep or be ready for pickup at your local grocery store, together with other items that you are running low on.
While you cannot expect that level of comfort from a smart device just yet, more and more devices in our households will have similar features that make our lives easier.

How smart devices connect to the internet

In most cases, smart home devices need internet access to function correctly, which means that you must tell your device how it can connect to your local network via a network name and password.
When you first set up a new smart device in your household, the process often looks like this:
  1. You connect the smart device to a power source.
  2. The smart device goes into setup mode.
  3. The smart device opens an ad hoc network (see https://en.wikipedia.org/wiki/Wireless_ad_hoc_network).
  4. You connect to the network provided by the smart device via your smartphone.
  5. On your smartphone, you visit a special website that is served by the smart device, and which is only accessible when you are connected to its network.
  6. You specify the network username and password on the website.
  1. The information is transmitted to the smart device.
  2. The smart device will close the temporary ad hoc network and connect to your normal network via the username and password you provided.
  3. The smart device can go online via your regular wireless network.
The very same technique can be used for creating IoT prototypes with microcontrollers, such as Arduino, Raspberry Pi, or Particle Photon, to create a convenient setup routine. We will not cover this technique in this book, but this is something to keep in mind if you're thinking about giving a prototype to friends and family or with batch production.
For example, if you were to bring your prototype to your friend's house, it would not be able to connect to the internet there, because it does not know the network name and password to connect with.
Without a setup routine like the one described previously, the source code of the device has to be modified each time the device is placed into a different environment to successfully connect to the other network.

Useful and unnecessary use cases

If you have ever lived in a single apartment without too much knowledge about how to separate your clothes when doing your laundry, you might have ended up with a bunch of pink shirts because a red sock found its way into your collection of white shirts that were to be washed. If you don't know what I am talking about, it is one of the mistakes a lot of single people make when using a washing machine. Washing a red sock with your white shirts is not a good idea, and might result in your shirts taking on the color of the sock, thereby becoming pink.
Other things can go wrong. You might do something wrong when setting the temperature, accidentally washing your favorite Norwegian Christmas sweater at 90 degrees, causing it to shrink. Now you might wear it while exposing your belly on cold summer days.
Chances are high that you don't want these things to happen.
Imagine that your shirts had a voice and that, when you asked them about their color and washing preferences, they answered, "Hi, my color is light-blue and I enjoy being washed at 30 °C. I will get sick when you tumble dry me, so please don't!". Now your washing machine could ask each and every textile lying in the washing machine drum about their washing preferences and set the program accordingly, or warn you that the red sock might better be off with the other red socks.
This can be made possible by using smart tags, such as RFID (short for Radio-Frequency Identification).
Many such use cases are about to bring value to our lives and make our lives easier. However, many companies forget about their product's original use case. One example is a smart light bulb that cannot be used as a light source when it is having a firmware update (https://twitter.com/BalrogGameRoom/status/1036644958973960192), which lasts for up to one hour. A firmware update probably does not need to be done very often, but if the light bulb is going through a firmware update in the evening, when it is dark, you will question their update policy and want to go back to using a normal light bulb.
I think updating the firmware on devices is important to keep the device secure and safe from hackers, but, in this case, the company producing these smart light bulbs could have spent more time developing a better update routine to improve the user experie...

Table of contents

  1. Title Page
  2. Copyright and Credits
  3. About Packt
  4. Contributors
  5. Preface
  6. Section 1: An Introduction to IoT and MQTT
  7. The Internet of Things in a Nutshell
  8. Basic Architecture of an IoT Prototype
  9. Getting Started with MQTT
  10. Section 2: Using MQTT in IoT projects
  11. Setting Up a Lab Environment
  12. Building Your Own Automatic Pet Food Dispenser
  13. Building a Smart E-Ink To-Do List
  14. Building a Smart Productivity Cube, Part 1
  15. Building a Smart Productivity Cube, Part 2
  16. Section 3: Prototypes
  17. Presenting Your Own Prototype
  18. Assessments
  19. Other Books You May Enjoy