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

Chapter 5: Building Your Own Automatic Pet Food Dispenser

  1. The # character is called a multi-level wildcard. By using it, we subscribe to all subtopics of the topic.
  2. In this project, we are using the public namespace with the try/try login credentials. It is neither secure nor private, and we just use it because it is easier and more tolerable for a prototype. If you want more security and privacy for your data, you need to use a private channel on Shiftr (or any other MQTT server with private channel functionality).
  3. If Shiftr stops working at some point, you can just move on to another (free) MQTT server (a list can be found at https://github.com/mqtt/mqtt.github.io/wiki/public_brokers). This is the beauty of MQTT: there are many implementations, and you can easily move on to another provider or simply create your own (local) server.
  4. You can control the smart pet food dispenser from any MQTT client. MQTT clients come in many shapes and sizes. You can control it using the Terminal (for example, using Mosquitto, which we installed in Chapter 3Getting Started with MQTT), using iOS or Android apps, or using macOS and Windows apps. You can also create a new Arduino project that also uses MQTT, and easily let the two Arduinos communicate using MQTT in the same way.
  5. Writing as little code as possible is the most efficient way of making your ideas a reality. When you find tiny examples or code snippets that solve parts of your problems, you should try to combine them instead of writing all of the code from scratch. You will be faster this way: you don't need to be an expert, and mostly using code that has been used by other people means that it will probably work when you use it.
  6. You really don't need to be an expert to build breathtaking prototypes. In the physical prototyping workshops I've held, many people who have never written code before built awesome prototypes anyway by combining examples, adding some code to glue them together, and making it look nice by spending time on building a case and hiding the (often ugly-looking) inner workings of the prototype.
  1. Please don't bet the life of your pet on your prototype working. As stated before, it is not secure, can probably fail in other ways, and should just be used as a prototype.
  2. There are many more things that you can build using just a servomotor and the techniques we used. Have a brainstorming session and try to come up with five ideas.