Book Image

Hands-On Internet of Things with MQTT

By : Tim Pulver
Book Image

Hands-On Internet of Things with MQTT

By: Tim Pulver

Overview of 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.
Table of Contents (16 chapters)
Title Page

Making your device smart

The detection of all of our cube sides is working now. Let's add MQTT to our code base:

  1. Open the MQTT example code from this book's repository: general/arduino/mqtt_shiftr_send_receive_example.

As we did in the other projects, let's run this test-code first before we integrate it into our main sketch to make sure the Wi-Fi, as well as the MQTT connection, is working.

  1. Enter your Wi-Fi name (WIFI_SSID) and Wi-Fi password (WIFI_PASSWORD). You can also customize MQTT_DEVICE_NAME. You will see it on shiftr.io when you look at the network graph.
  2. Pick any name you like here, but stick to the characters a-z, 0-9, and dash (-). Other characters might work as well but might also lead to problems with certain MQTT clients or servers.
  3. Try to make your device name unique (for example, by appending a few random numbers). The device name...