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

Hands-On Internet of Things with MQTT: Build connected IoT devices with Arduino and MQ Telemetry Transport (MQTT)

Arrow left icon
Profile Icon Tim Pulver
Arrow right icon
Free Trial
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.2 (5 Ratings)
Paperback Oct 2019 350 pages 1st Edition
eBook
zł59.99 zł141.99
Paperback
zł177.99
Subscription
Free Trial
Arrow left icon
Profile Icon Tim Pulver
Arrow right icon
Free Trial
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.2 (5 Ratings)
Paperback Oct 2019 350 pages 1st Edition
eBook
zł59.99 zł141.99
Paperback
zł177.99
Subscription
Free Trial
eBook
zł59.99 zł141.99
Paperback
zł177.99
Subscription
Free Trial

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Hands-On Internet of Things 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 experience.

Often, smart devices only work under perfect conditions, in this case, with updated firmware. Compared to non-smart devices (in this case, a normal light bulb), this is a huge step backward. A normal light bulb has one purpose: provide light when it has power. Either it works or it does not. Adding internet capabilities to a device might not always be the best decision, as it produces problems such as the one mentioned previously. The device should be created in a way that means that using its core feature is not disturbed if there's no internet connection or outdated firmware.

Many companies that develop smart devices overemphasize the smartness of their products and forget about their original use case, reducing the usability of the device, which was its main purpose. Not all things need to be smart, and if they are made smart, then their main feature should work even without internet access.

In another example, two security researchers discovered a vulnerability in a smart vacuum cleaner modela robot equipped with a camera cleaning your flat autonomously. According to their study, it is not too hard to get access to the vacuum cleaner with admin privileges, allowing an attacker to misuse the vacuum cleaner as a 360º spying device. Definitely not what you signed up for when buying a smart device to save yourself some time. In this case, the manufacturer should have spent more time securing the device properly to make sure it is safe from hacker attacks.

There definitely is a need for autonomous vacuum-cleaning robots, smart light bulbs, and probably smart coffee machines, but when building new smart devices, you should always critically decide whether adding internet access to the device really adds something to its utility. If it does, then you should bear in mind the following questions when thinking about these aforementioned edge cases:

  • What happens when the device is not able to reach the internet? Is it still usable?
  • Can the device be updated? If so, when will it be updated? Does an update block its main functionality?
  • Is the device secure enough? Or will it be easy for hackers to access the device and use it for their purposes?

If you want a few hours of entertainment (and education), you should check out the Twitter account https://twitter.com/internetofshit, which collects IoT fails and available smart devices of little use. It will not only bring a smile to your face but also make you realize that things went too far for some companies when dealing with smart home devices. The first question to ask yourself should always be: Is the thing I am about to build useful? Just making something smart certainly does not make it more useful, but instead might make it vulnerable to hacker attacks or completely useless when the internet connection does not work.

Exploring smart cars

Smart cars, another emerging field associated with IoT, is gaining momentum. Its progress is closely connected to the advancements made in machine learning in the last decade. If you have never heard about machine learning, you should put this book aside for a second and watch the TED talk The Rise of Artificial Intelligence through Deep Learning by Yoshua Bengio (https://www.youtube.com/watch?v=uawLjkSI7Mo). In a nutshell, machine learning makes it possible for computers to learn just like our brain does. It is another future technology that will be paired with IoT more and more to create smart, self-learning devices.

Machine learning is used in smart cars to develop many of its essential features:

  • Detect the street, other cars, and people
  • Understand signs and speed limits
  • Identify dangerous situations and know how to solve them (for example, by applying the brakes)

The following screenshot shows a simplified view of object detection in a smart car:

A simplified view of object detection in a smart car (image based on photo by Josh Sorenson)
Source : (https://www.pexels.com/photo/architectural-design-asphalt-buildings-city-139303/)

If you compare the visual interpretation of a human's view of a street and the digital representation of the same theme, the two differ enormously—a computer seeing through a camera just sees raw data, the amount of red, green, and blue per pixel, and nothing more. Machine learning makes this data more usable by training the computer based on input footage—for example, by supplying a large number of images depicting street views.

After many learning iterations, the computer might be able to identify a street using fresh footage. Machine learning and IoT will be good friends in the future as internet-enabled microcontrollers become smaller and more powerful.

Currently, complex machine learning models require an expensive state-of-the-art computer, but there are already experiments using the Raspberry Pi, a tiny computer that runs Linux, for simple machine learning tasks. Google and NVIDIA introduced two new development boards (so-called edge devices) in 2019, which have a similar form factor to the Raspberry Pi and are intended for machine learning prototyping: Google Coral and NVIDIA Jetson TX2.

But so-called on-device training is not the only way hardware devices can use the power of machine learning. The most common way they use machine learning today is by sending the device's data to a cloud server where the heavy analysis is done. One example of this is Google Photos. It allows you to upload your photos, in most cases taken with a smartphone, to the Google servers. The servers will analyze each and every one of them using various machine learning models.

You can already use the results in two ways, as:

  • The machine learning model detects all faces in a photo and groups them together into categories. This way you can easily find all photos that contain your face or any of your friends' faces.
  • The machine learning model detects objects in photos. You can then, for example, filter all of your images that contain a red car. 

Apart from machine learning, to understand their surroundings, smart cars can communicate with each other. Every now and then there are reports about a mass crash on the highway. Smart cars will be able to warn each other about dangerous situations: "Attention cars behind me. There is an obstacle lying on the street. Better slow down!".

When it comes to situations like this, the amount of time it takes for another car to receive this information can make the difference between life and death—one or even multiple seconds response time is just not good enough here, the response time needs to be in the milliseconds. If the cars were using the internet for communication, it might take too long. When sending data to a satellite and spreading it from there to all of the nearby cars, there are too many things that can go wrong and prevent the warning from being delivered in time. Fortunately, there is a solution for this: using a technology called Vehicle to Vehicle (V2V). With this technology, cars can talk directly to each other by opening a network themselves (like a router). Using this, they create a mesh of connected cars without needing internet access.

Exploring industry 4.0 / the Industrial Internet of Things

Industry 4.0 refers to the fourth industrial revolution. One of its driving technologies is IoT, connecting physical machines digitally with each other and the cloud.

Industrial robots (source: Depositphotos)

According to IoT Fundamentals: Networking Technologies, Protocols, and Use Cases for the Internet of Things, by David Hanes (et al.), (2017, Cisco Press), p 932-933, 1208-1209:

 "There are estimates that there are 60 million machines in factories; the vast majority of them are more than 15 years old and 90% are not connected to the internet."

In the airplane industry, preflight security checks involved a lot of manual work—each and every piece of essential equipment had to be checked off a list for the flight to be considered safe. On average, this took 6.5 hours per plane.

By integrating RFID tags into essential safety equipment, for example, the airplane industry made it possible for security staff to use an RFID scanner instead of a paper checklist to make sure that no important parts are missing. 

And adding these chips was worth it. The 6.5 hours it took to manually check for the presence of each part could be reduced to 20 minutes this way.

There are many more industries less modern than the airplane industry that can profit from IoT as well.

By 2016, approximately 20 million smart meters had been installed globally, which can send their data automatically to the cloud. One of the areas where this is being used is power consumption in apartments.

Using smart meters and a web interface, tenants can check their monthly energy consumption. This way, it is easier to identify electronics or usage patterns that require a lot of energy, just by comparing the monthly costs.

Without smart meters, it is hard to tell whether the new electric grill you just bought is actually a power hog. You can imagine how much easier it is for the power companies as well: no need to send a technician from apartment to apartment, writing down numbers on paper that then have to be typed into a computer later.

Smart meters make everything much easier.

One of the areas where a lot of man-hours can be saved is semiautomatic maintenance of machines. Every machine part has a certain life expectancy: some fragile parts may last a few weeks, some several years. But sooner or later, physical parts need to be replaced. Most factories rely on their machines running in parallel—once one of them stops, the flow cannot go on.

Detecting machine parts that need to be replaced before they actually break can save the company a lot of analysis work and money. With self-monitoring machines, this is about to become more efficient and involve less human maintenance work. By equipping machines with various sensors to run self-tests and verify that all of their parts operate as planned, malfunctions or old parts can be identified early on by the machine. It can then call for a technician to replace part x or manually check part y. By pinpointing possible problems this way, machine downtime can be minimized.

The same self-analysis functions have found their way into the consumer market more and more as well. Commercial coffee machines have an internal counter that is incremented every time a coffee is made. After x coffees have been made, the machine might blink an LED to prompt you to run a manual maintenance program, for example, to get rid of unwanted deposits. While this isn't too smart, modern consumer 3D printers actually are. Being equipped with a multitude of sensors, they can detect malfunctions, identify broken parts, and fine-tune their own settings while printing.

Prototyping for the greater good

Building IoT devices can also contribute to the greater good in a non-commercial setting. In 2018, a non-governmental organization consisting of engineers and developers called Rainforest Connection (https://rfcx.org/developed an IoT device to help to protect the Amazon rainforest from illegal deforestation. As it reduces the levels of greenhouse gases in the atmosphere, the rainforest plays an important role in our climate, and, according to Rainforest Connection's CEO Topher White, illegal deforestation accounts for nearly one-fifth of all the greenhouse gas emissions every year. Up to 90% of the deforestation of the Amazon rainforest is done illegally. Saving the rainforest could be the cheapest and fastest way to slow down climate change:

African jungle (source: Depositphotos)

In collaboration with the indigenous Tembé tribe, Rainforest Connection developed a device called Guardian to detect illegal deforestation and prevent it from happening. The devices are based on recycled smartphones, which have many of the ingredients of an IoT device on-board—a microprocessor, sensors, and a way to communicate via the cell phone's network over the internet.

The Guardians are hung inside the trees, their microphone transmitting the ambient sound via the cell phone network 24/7, forming a huge grid of microphones. In the cloud, where all of this data is assembled, a machine learning model based on Google's open source TensorFlow library comes into play. It was trained to detect the sound of chainsaws and trucks used in deforestation operations. Whenever one of the microphones detects a sound like this, disturbing the natural sound collage, the machine learning algorithms can identify it and the relevant information, such as GPS data, can be forwarded to the authorities.

In March 2018, the Planet Guardians program was launched by Rainforest Connection. Students from Los Angeles helped to build new Guardian devices to be added to the grid, and it is expected that these will help to protect 100,000 acres of rainforest throughout the year 2020 (you can go to https://www.blog.google/technology/ai/fight-against-illegal-deforestation-tensorflow/ and https://www.prnewswire.com/news-releases/rainforest-connection-introduces-one-of-the-largest-programs-ever-launched-by-students-to-protect-the-worlds-rainforests-300617270.html for more information).

Similarly, devices equipped with GPS and a sensor are used to detect earthquakes—once an earthquake is detected by the sensors, people can be warned accordingly.

The same principle can be used for other areas as wellas an early warning system for tsunamis or avalanches, for example.

What is a prototype?

Before starting to work on your prototype, it is important to understand what a prototype is and what it is not. From a product perspective, various things need to be evaluated before a device can be produced in batches, starting with the functionality. Is the device useful? Does it serve a purpose? You also might want to find out how it feels. What material is it made of? Does it feel good when you hold it in your hands? How does it look? Do the buttons have a nice degree of resistance to pressure? Is it fitting in to its environment? Is it easy to use? Does it need a manual? Where can you get all the materials for batch-production?

Hardware prototyping (source: Envato Elements)

If your device is supposed to be outside, you also need to find out which materials can be used for it to survive the wind and rain. For all of these questions, you might want to produce one or many prototypes to get closer to a possible product, step by step.

A lot of the areas mentioned previously can be tackled individually—to find a nice form factor, you might design various models in a 3D application, print them out, and iterate upon them. The material used can also have a huge impact. By using online services such as Shapeways (https://www.shapeways.com), you can have a 3D printing service at hand that can print in various materials, such as plastic, aluminum, and gold. That last one might be a bit expensive, but at least you have the option. Combined with other rapid prototyping techniques, such as CNC milling or laser cutting, the possibilities are endless.

While building the prototype, it is essential to find out quickly whether your idea works, both from a usability perspective and from a technical perspective.

To evaluate the usability and usefulness of the device, you might not need to tinker at all. When developing software interfaces—for example, a design for an application—it is common to create so-called paper prototypes—a piece of paper for each state of the interface:

A paper prototype is used by designers to evaluate their idea as fast as possible (source: Depositphotos)

When evaluating whether the interface is working, a guinea pig needs to simulate using the interface, for example, by pointing on the piece of paper and saying "I'm pressing the blue button".

The person testing the interface can then exchange the piece of paper for another one showing the resultant screen, as if a button was clicked on a working prototype on the computer, to show the new state. By doing this, many problems will be uncovered before a line of code is written. The same principle might be used for hardware prototyping. Let's say that you have a device with a button and an LED that can either turn red, green, or blue, depending on how often you press the button. If you actually draw a sketch of this prototype on paper, one page for each state (for example, one page where the LED is red, one where it is green, and one where it is blue) and simulate the usage, you might notice that, when pressing the button, you cannot see the LED anymore because your hand is covering the LED when pressing the button.

Hooray, you just discovered a usability problem that might have cost you hours of work if you had started soldering right away. Prototyping 3D objects with 2D paper is definitely not optimal, but it might save you some time anyway. The key is to evaluate multiple parts of your design fast to find out what works and what needs to be developed.

This is equally true from a technical perspective. Try breaking down your problem into multiple small problems to evaluate each one individually, especially when you don't feel comfortable with electronics. Let's say you want to build a device that reads a sensor value, and, when a button is pressed, tweet its value. You could build three mini sketches here to make sure each of the needed functionalities works individually:

  • Sketch #1 might output a button press. With this sketch, you can verify that you connected the button in the right way and that its value is correct (pressed or not pressed).
  • Sketch #2 might output the value of the sensor to the console. Interact with the sensor and find out whether the value is what you expected it to be. When using a distance sensor, it might actually only work in a very specific range and would not at all be usable for your idea. Hooray again, you saved yourself some time by failing fast, instead of spending hours on something that was always going to end up in the trash.
  • Sketch #3 might just send a tweet.
  • Sketch #4 might then combine all of the sketches to create the actual prototype you are after. When working on prototypes, I like to keep loose ends to a minimum. By working this way and validating different parts of your prototype early and in an isolated fashion, you will be more comfortable bringing it all together, and possible problems will be easier to pinpoint.
A sketch is a program that is uploaded to a microcontroller, such as an Arduino microcontroller. It is a widely used term and is used interchangeably to refer to a program or code snippet. It is a reference to sketches made by an artist and is used in Processing, the graphical development environment similar to Arduino (https://www.processing.org).

The beautiful thing about prototyping is that you don't need to be an expert in every area—you will find code snippets and diagrams for most of the common types of sensors and actuators around the internet, especially in the Arduino community. Combining example snippets and adding a little bit of logic to the code might do the job for a first version. 

When prototyping for IoT, a main ingredient is connectivity. When starting new projects, making sure that the microcontroller can connect to the internet is one of the first things I do.

One of the areas that clearly goes beyond a prototype for IoT is security. Making sure your device is well protected against hacker attacks is another issue to be tackled once you actually finish your prototype. If you think about batch-producing a device, this is a topic that needs to be addressed and well researched so that your product isn't hacked and doesn't end up on the Twitter account https://twitter.com/internetofshit.

Voice control

With Apple's Siri, Microsoft's Cortana, Amazon's Alexa, and Google's Assistant, smart voice interfaces have found their way onto each of our smartphones, and they are about to be found in more and more gadgets in our homes:

Waveform (source: Envato Elements)

The newest generation of smart speakers brings the vocal assistant as a key feature, not only allowing us to listen to our favorite tracks, streamed from Spotify via Bluetooth from our smartphones, but also acting as an interface to the web.

Using voice assistants to get the weather forecast for the day, find out what the capital of Finland is, or create a reminder to buy the milk makes these tasks a lot easier.

Natural voice interfaces open up a door to the connected world to control our homes and gain easy access to information. The technology is still young and full of flaws—many questions that you might ask the digital assistant are not understood yet, and result in an answer like "Sorry, I could not understand you. Did you mean…?". The complexity of conversations is also far off from resembling natural conversations between humans. Asking one of the voice assistants "How is the weather tomorrow?" is an easy task and the response will most likely be helpful to you and will let you know whether you should pack an umbrella or not. Asking a follow-up question such as "And the day after?" is a completely different problem and has not been supported until very recently.

Because of advancements in machine learning, these problems are about to be tackled, and the assistants get better each year, respond to more complex questions (and follow-up questions), and behave more and more like humans.

You might be wondering what all this has to do with IoT. When working on IoT projects, and especially wearables, you might have strict spacial restrictions. Let's say you want to create an LED necklace that can change color—being able to change the color would require physical buttons, which would take up extra space. It would also often feel hard to use without adding a display. This could already be too much to carry around. Using a voice assistant for this case would feel way more natural. The necklace could have one button to activate the assistant; once it is pressed, you could tell your necklace to change its color to blue, for example, using an external voice recognition service such as the Google Speech-to-Text API. From the API, you would then get the text blue back, which you could use in your Arduino code to actually switch the color.

Using external services and premade modules is one of the things I really want to push you toward. Creating a prototype is not about creating a consumer-grade product, ready to be produced in a batch of 50,000 in a factory in Shenzhen and hand-coded in tens of thousands of lines of code. Creating a prototype is about succeeding (or failing) fast in creating a functional prototype, either because you really want to build your own smart coffee maker or you want to find out whether that idea you had for your company might actually help with digitalization. Use whatever is available, hack it together. If one of the components is a proprietary voice recognition library, it is alright. If your prototype is doing well and you are thinking about bringing it to the next stage and actually producing it, you can still look for alternatives.

Why should you invest in IoT?

For one, working on hardware projects can be very fulfilling. In contrast to software, hardware prototypes are physical. They can be looked at from multiple viewpoints, touched, and taken with you. There is something magical about seeing your creation work on an actual device, and this is even more true with internet-enabled devices. Building a device that interacts with another device wirelessly is magical × 2.

Artificial intelligence (AI)—deep learning, image recognition, natural-language processing, and neural network-driven decision-making are advancing every year, and the possibilities of combining IoT with AI open up completely new possibilities (for more information, see https://www.forbes.com/sites/bernardmarr/2018/01/04/the-internet-of-things-iot-will-be-massive-in-2018-here-are-the-4-predictions-from-ibm/#62a82b48edd3).

IoT, with all of its devices, is connected closely to the concept of big data. Many companies want to analyze all of the sensor data stored in the cloud to draw conclusions from it that can then be used to maximize their profits. Here, machine learning comes into play to make use of the data and create rules to act upon.

Combined with modern frontend tooling using HTML, CSS, and JavaScript, it is possible to create, in just a couple of weeks, a working prototype of a sensing, internet-connected device in a nice case that analyzes its data using machine learning and presents its results and controls in a nice-looking web dashboard. Ten years ago, you would have needed a large budget and a lot of manpower for this task; now it can be done by only one creative technologist.

Summary

We now have a fair idea about the most important areas related to the Internet of Things.

One thing that all IoT devices have in common is their connectivity—equipped with an internet connection, they can send and receive information, sense their surroundings, collect data, and control physical actuators. To be available over the internet, these devices need to have unique identifiers, usually in the form of their IP addresses.

You learned that IoT is being used in smart homes in the form of connected devices (for example, smart fridges and smart heating systems). This area has the most possibilities for your own experiments using an Arduino, sensors, and actuators.

We also had a look at two other areas where IoT is being used that gain a lot of traction: smart cars and industrial IoT. Smart cars will take over our streets and (at least partly) replace regular cars. The industrial IoT will help to automate factories around the world, improve efficiency, and minimize the need for manual maintenance.

You learned how a prototype differs from a product and that building quick-and-dirty experiments is often the fastest way to validate your ideas.

You also got a glimpse of voice control and learned that technologies such as Siri and Cortana can be used in physical prototypes as well.

While many of the use cases of IoT are in the commercial space, there is also a lot of room to create prototypes for the greater good using IoT development boards as you learned in the section about the Guardian, a device to help in stopping illegal deforestation.

In Chapter 2, Basic Architecture of an IoT Prototype, you will learn more about the IoT ecosystem—microcontrollers, protocols, apps, and libraries.

Questions

  1. Name three areas related to IoT.
  2. Name one user interface trend for internet-connected devices.
  3. Does it make sense to make every gadget smart?
  4. What is a prototype?
  5. Do you need to be an expert to create IoT prototypes?

Further reading

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • 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

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.

Who is this book 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.

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

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Oct 04, 2019
Length: 350 pages
Edition : 1st
Language : English
ISBN-13 : 9781789341782
Category :
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Oct 04, 2019
Length: 350 pages
Edition : 1st
Language : English
ISBN-13 : 9781789341782
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just zł20 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just zł20 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 553.97
Hands-On Internet of Things with MQTT
zł177.99
MQTT Essentials - A Lightweight IoT Protocol
zł177.99
Hands-On Industrial Internet of Things
zł197.99
Total 553.97 Stars icon

Table of Contents

9 Chapters
The Internet of Things in a Nutshell Chevron down icon Chevron up icon
Basic Architecture of an IoT Prototype Chevron down icon Chevron up icon
Getting Started with MQTT Chevron down icon Chevron up icon
Setting Up a Lab Environment Chevron down icon Chevron up icon
Building Your Own Automatic Pet Food Dispenser Chevron down icon Chevron up icon
Building a Smart E-Ink To-Do List Chevron down icon Chevron up icon
Building a Smart Productivity Cube, Part 1 Chevron down icon Chevron up icon
Building a Smart Productivity Cube, Part 2 Chevron down icon Chevron up icon
Presenting Your Own Prototype Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.2
(5 Ratings)
5 star 40%
4 star 0%
3 star 20%
2 star 20%
1 star 20%
U.We. May 28, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I bought this book hoping to get a gentle introduction into the world of MQTT with the Arduino platform and wasn't disappointed.What I really like about this book is that some of its chapters serve as a reference on key topics (which I might revisit at a later point) while others are hands-on tutorials to build entertaining projects (e.g. a pet feeder that can be controlled via smartphone).To be honest the projects are not that special (quite simple), but they were easy to follow. I definitely prefer simple (but limited) example projects over too complicated ones that mix up a lot of different technologies, but don't explain what is going on.Another thing that I liked is the MQTT platform being used (Shiftr). This makes it super easy to understand how the MQTT messages are sent around.Would I recommend this book? Definitely!
Amazon Verified review Amazon
etlam May 10, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Die Themen sind gut erklärt (auch für Leute mit wenig Arduino-Erfahrung wie mich). Das Buch reißt einiges an Themen an, etwas knapp teilweise, aber oft werden weiterführende Links zu Youtube oder Artikel zum Weiterstöbern geboten.Es wird recht wenig an Vorwissen vorausgesetzt und man kann dem Inhalt gut folgen. Für Arduino-Profis könnte es etwas langatmig sein, die Zielgruppe sind hier wohl eher Anfänger und Fortgeschrittene.Mit MQTT lässt sich echt eine Menge machen. Hätte nicht gedacht, dass es so einfach ist Nachrichten zwischen mehreren Arduinos, dem Smartphone und Computer hin und her zu schicken.
Amazon Verified review Amazon
Code Wrangler Nov 14, 2019
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
I got a copy of this book to review and while it's OK for the beginner setting up SSL for MQTT is a must for any serious IoT book. How many IoT devices have been hacked as a result of poor security (think security cameras, etc.). I even provide how to configure this with a sample project on my github site.
Amazon Verified review Amazon
John L Nov 15, 2023
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
There is a lot of code in the book. By chapter 4 you’ll find out it’s already outdated. Would not buy until it’s updated.
Amazon Verified review Amazon
Kiran Salunkhe Jul 20, 2020
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
Need book not kindle
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.