Introduction to MQTT

Pages
Contributors: Alex the Giant
Favorited Favorite 13

Introduction

In this tutorial, you'll learn everything you need to know about the MQTT messaging protocol, why you would want to use it, and how it's implemented. In a nutshell, MQTT uses your existing Internet home network to send messages to your IoT devices and respond to those messages.

MQTT Nodes

Brief History

MQTT (Message Queuing Telemetry Transport) is a publish/subscribe messaging protocol that works on top of the TCP/IP protocol. The first version of the protocol was developed by Andy Stanford-Clark of IBM and Arlen Nipper of Cirrus Link in 1999. What makes MQTT faster than say sending HTTP requests with your IoT device is MQTT messages can be as small as 2 bytes, whereas HTTP requires headers which contains a lot of information that other devices might not care about. Also, if you have multiple devices waiting for a request with HTTP, you'll need to send a POST action to each client. With MQTT, when a server receives information from one client, it will automatically distribute that information to each of the interested clients.

Required Materials

To follow along with the example in this tutorial, you will need the following pieces of hardware. You may not need everything though depending on what you have. Add it to your cart, read through the guide, and adjust the cart as necessary.

Optional Materials

Depending on your setup, you may also need the following.

microSD Card with Adapter - 16GB (Class 10)

microSD Card with Adapter - 16GB (Class 10)

COM-13833
$19.95
5
Raspberry Pi LCD - 7" Touchscreen

Raspberry Pi LCD - 7" Touchscreen

LCD-13733
$64.95
39
LCD Touchscreen HAT for Raspberry Pi - TFT 3.5in. (480x320)

LCD Touchscreen HAT for Raspberry Pi - TFT 3.5in. (480x320)

LCD-14776
$24.95
1
Multimedia Wireless Keyboard

Multimedia Wireless Keyboard

WIG-14271
$29.95
3

[//]: # For reference https://learn.sparkfun.com/tutorials/python-gui-guide-introduction-to-tkinter/all#introduction

Suggested Reading

If you aren't familiar with the following concepts, we recommend checking out these tutorials before continuing.

Raspberry Pi 3 Starter Kit Hookup Guide

Guide for getting going with the Raspberry Pi 3 Model B and Raspberry Pi 3 Model B+ starter kit.

ESP32 Thing Hookup Guide

An introduction to the ESP32 Thing's hardware features, and a primer on using the WiFi/Bluetooth system-on-chip in Arduino.

Getting Started with the Raspberry Pi Zero Wireless

Learn how to setup, configure and use the smallest Raspberry Pi yet, the Raspberry Pi Zero - Wireless.

How to Use Remote Desktop on the Raspberry Pi with VNC

Use RealVNC to connect to your Raspberry Pi to control the graphical desktop remotely across the network.