Home IoT & Hardware Hands-On Internet of Things with MQTT

Hands-On Internet of Things with MQTT

By Tim Pulver
books-svg-icon Book
eBook $29.99 $20.98
Print $43.99
Subscription $15.99 $10 p/m for three months
$10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
BUY NOW $10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
eBook $29.99 $20.98
Print $43.99
Subscription $15.99 $10 p/m for three months
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
  1. Free Chapter
    The Internet of Things in a Nutshell
About this book
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.
Publication date:
October 2019
Publisher
Packt
Pages
350
ISBN
9781789341782

 

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

About the Author
  • Tim Pulver

    Tim Pulver is a Berlin-based freelance interaction designer and developer. In his work, he combines his physical prototyping experience and knowledge of interface design with modern technologies such as 3D printing, laser cutting, web technologies, and machine learning to create unique interactive experiences. In recent years, he has worked on interactive data visualizations, web-based audiovisual experiences, musical interfaces, and cables an innovative browser-based visual programming language that enables the creation of interactive audiovisual prototypes without writing any code. He holds a Bachelor of Arts degree in interface design from the University of Applied Sciences in Potsdam, Germany.

    Browse publications by this author
Latest Reviews (3 reviews total)
Kwalitatief goede boeken
It is a great book on how start IoT. It describes the MQTT protocol and how to setup the working environment. Also, there are some projects where the reader can have an idea of how IoT device should work.
très bon livre
Hands-On Internet of Things with MQTT
Unlock this book and the full library FREE for 7 days
Start now