Reader small image

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

Product typeBook
Published inOct 2019
Reading LevelIntermediate
PublisherPackt
ISBN-139781789341782
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Tim Pulver
Tim Pulver
author image
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.
Read more about Tim Pulver

Right arrow

Setting Up a Lab Environment

In this chapter, we will look at the shopping list for all of the components that you will need for the hands-on part of this book, and we will also set up all of the necessary tools and libraries. Furthermore, we will set up an account for the web service, shiftr.io, which can be used for free as a cloud-based MQTT server and visualization tool. We will also explore the instructions for macOS and Windows.

In this chapter, we are going to cover the following topics, which are necessary for working on the hands-on projects in this book:

  • The hardware shopping list
  • Installing the essential tools and libraries
  • Understanding the shiftr.io web service
  • Troubleshooting

Hardware shopping list

Before we start coding, you will need to order the necessary parts in order to get going. The components that are listed under General components will be needed for all three projects. Please don't forget to order the parts that are needed for the individual projects. They are listed in the following sections of this chapter: Project 1: a pet food dispenser, Project 2: a smart e-ink to-do list, and Project 3: a smart productivity cube.

To reduce costs, I have listed only one Arduino MKR WiFi 1010 development board in the shopping list, which means that you will have to disassemble a project in order to follow along with another one.

You will find an updated shopping list (with links) in the GitHub repository for this book. Instead of searching for the parts manually, have a look at the GitHub repository. Paper books cannot be updated easily...

Installing the essential tools and libraries

In this section, we are going to install all of the tools that we will need in the hands-on part of this book: the Arduino IDE to upload code, Arduino MKR WiFi 1010 board drivers, Visual Studio Code to open non-Arduino code files, and Mosquitto, an MQTT server and toolkit for easy prototyping.

We will also set up an account on shiftr.io, a free MQTT web service, which comes with a useful dashboard.

Additional libraries, which are only needed in one of the hands-on projects, will be set up in that specific chapter.

Installing Arduino

The first application that we are going to install is the Arduino integrated development environment (IDE). It will be used in all of the hands-on...

Understanding the shiftr.io web service

shiftr.io is a unique web service that makes working with MQTT a breeze. Using a graph-based real-time visualization, debugging MQTT messages becomes very easy:

The website of shiftr.io—the network in the background is an actual representation of an MQTT network; the text and numbers in this image are intentionally illegible

As you have probably noticed in previous chapters, I am not a huge fan of proprietary, closed web services, mainly because of the lock-in effect. If you create an application that uses a certain web service, in most cases, you are tied to it. Your code will only work if the web service is online, and if you decide to move to an alternative web service provider, you often have to put in a lot of effort to make your code work on the other platform. For platforms that are built around MQTT, this effort is minimized...

Troubleshooting

If you had any problems with setting up one of these tools, or if you run into any problems during the projects in this book, feel free to open an issue in the repository for this book on GitHub (https://github.com/PacktPublishing/Hands-on-IOT-with-MQTT/issues), and I will do my best to help you to fix it. Installing Mosquitto especially can be tricky at times, even more so on Windows.

Don't be shy! If you have a problem, chances are that another reader also has the same problem. You could find it in the issue list and be presented with a solution. If you do not find a solution to your question, just create a new issue. You will need a GitHub (https://github.com) account to do so.

Also, please have a look at the main page of the repository (https://github.com/PacktPublishing/Hands-on-IOT-with-MQTT). Here, you will find all of the updated information in the...

Summary

The purpose of this chapter was to prepare you for the following hands-on chapters, by giving you a list of materials that you will need, as well as installing all of the tools that we are going to be using. 

Together, we set up an account on shiftr.io, the MQTT web service that we will be using throughout this book. We created a private namespace, together with a token. This makes it possible for you to have your own MQTT area, to which only you can publish MQTT messages. On the shiftr.io website, you can inspect all of the devices that are connected to your MQTT network, and the messages that are being sent to your namespace. You also learned how to deal with the problems that you encounter on the way, and where to look for solutions.

The knowledge that you have acquired in this chapter will help you immensely in the hands-on projects that we will explore in the...

Questions 

  1. How do you send a message using Mosquitto?
  2. How do you subscribe to messages using Mosquitto?
  3. What does -t stand for when using the Mosquitto commands?
  4. What does -m stand for when sending messages via MQTT?
  5. Have a look at the explore page of shiftr.io (https://shiftr.io/explore). Here, you will find public namespaces from other people. How do they use shiftr.io and MQTT? Can you tell by looking at the namespaces, topics, and connected clients? How do other people organize their topics? Which structure do they use?
  1. Try opening a few other tabs and sending messages from each of them. Open another one and experiment with subscriptions. Do you remember how they work? You can use slashes to create sub-topics (for example, /test/sub-topic), or use wildcards to subscribe to multiple topics at once (for example, /test/#), which will get an update once...

Further reading

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

Author (1)

author image
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.
Read more about Tim Pulver