Jan 12, 2023

What is MQTT and why it is important for the Internet of Things

Alexis Leibbrandt

This article describes what MQTT is, explaining the concept of the publish and subscribe model, and why it is important for IoT.

What is MQTT?

The first thing you need to know about MQTT is that it stands for Message Queuing Telemetry Transport. It is a standard messaging protocol designed specifically for use in IoT applications.

MQTT was developed by Andy Stanford-Clark and Arlen Nipper, who were working at IBM’s Cambridge software lab. The protocol has become very popular with the Internet of Things because it provides a publish and subscribe model, making it easy to create connectivity between various devices or sensors.

The MQTT protocol is based on TCP/IP under the OASIS standard.

How does MQTT work?

As discussed previously, the MQTT protocol follows a publish and subscribe model. The publish and subscribe model is designed to allow messages to be sent in either direction between client and server. This provides a way for IoT devices to create connectivity with one another, regardless of their geographical location. The MQTT protocol guarantees that messages are delivered even when networks are unreliable or unresponsive. It uses an acknowledgment system that lets both sides know whether data was received correctly or not.

Let's take a deeper look at the publish and subscribe model.

The publish and subscribe model

In this model, one device called the publisher, sends out messages to any other device interested in receiving them - this could be an individual sensor or another type of internet-connected machine like a server.

Those devices that want to receive data from the publisher, called subscribers, send back an acknowledgment if they received it correctly.

The publishers and subscribers of the system do not interact with each other directly. Instead, a broker handles the connection between the two entities by filtering all incoming messages and distributing them to the correct subscribers.

The MQTT protocol represents these concepts with the MQTT broker, MQTT clients, and MQTT topics, see below.

Image copyright https://mqtt.org/

MQTT broker

The broker is at the heart of the system. It is responsible for receiving all messages, filtering them, and sending them to the subscribers, here the MQTT clients. An MQTT broker can potentially handle millions of connected MQTT clients.

MQTT client

A client is basically any device that can interact with the broker to send and receive messages. A client can be a tiny IoT sensor delivering data at constant intervals or a smart application on a computer with a graphical representation of the IoT data.

A client can subscribe to a given topic in the broker to receive the corresponding messages of that topic. Similarly, a client can publish messages under a given topic to be forwarded by the broker to the subscribers of that topic.

MQTT topic

Topics are used to register interest in a specific incoming message type and, conversely, to specify where to publish outbound messages.

An MQTT topic can contain several topic levels, separated by a forward slash.

Here are some examples of topics:

mycompany/meetingroom/temperature

mycompany/meetingroom/lamp

The above diagram shows a possible implementation of the MQTT topics described previously. Here the akenza platform serves as MQTT broker in the system

Why is MQTT important for IoT

In recent years, MQTT has become one of the main protocols for IoT solutions. This is due to several factors.

First, it is one of the most lightweight protocols currently used in IoT. It's an open standard that can be implemented on any hardware or software. Client libraries are available for all major programming languages, which makes it easy to build IoT applications using MQTT.

Thanks to the publish and subscribe model, the flexibility MQTT offers makes it possible to support different types of use cases and IoT project architectures. Note that publishers and subscribers of the system do not even need to know about the existence of each other since the broker handles all connections.

The protocol allows implementing of highly scalable projects, possibly connecting millions of IoT devices in a system. The bi-directional communication of MQTT allows broadcasting messages to large groups of devices.

Finally, MQTT supports numerous authentications and data security mechanisms such as TLS encryption.

Harnessing the power of MQTT: a practical example of IoT integration

The Hycleen Automation System (Hycleen AS) by Georg Fischer is a sanitary automation system for large facilities. It ensures correct water circulation in the buildings and optimal hygienic conditions. The system is composed of water-balancing valves connected to a central master unit. Initially, the master unit could only be calibrated and controlled on-site. As this was a limiting factor, the product underwent a transformative upgrade, leveraging the power of MQTT to connect the product to the cloud. In the current version, the firmware of the Hycleen master device supports bi-directional communication via MQTT, enabling cloud connectivity without the need for additional hardware development. Facility managers can now control the sanitary system of various buildings remotely from one central platform.

The Hycleen Automation System

How to integrate an Arduino device via MQTT on akenza

The akenza IoT platform supports the connection of IP-enabled devices via MQTT (in addition to HTTP, CoAP, and LoRaWAN) and acts as the MQTT broker in the system (via Eclipse Mosquitto).

To get you started with MQTT on akenza, we prepared a short tutorial that will guide you through the integration of an Arduino device via MQTT in a few simple steps:

How to integrate an Arduino device via MQTT on akenza

The Arduino Uno WiFi Rev2 used in the tutorial

Need help with your IoT project?

To learn more about how akenza can help you build smart solutions with ease, contact us or directly sign up for a free trial today.

Changelog

If you want to follow the latest updates and upcoming features of akenza in real-time, be sure to check our changelog.