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

Published on by Alexis Leibbrandt

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.

MQTT TCPIP protocol stack

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 correct subscribers.

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

Mqtt publish subscribe

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 and 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:

Akenza blog mqtt

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.

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

Arduino Uno Wi Fi Rev2

The Arduino Uno WiFi Rev2 used in the tutorial

Recent blog posts
Trends preview image v1 min
7 Trends for IoT in 2023

This article covers the 7 trends for IoT that are shaping the market in 2023.

Read the post
Blogpost preview image kickstart your Io T Project
How to Kickstart Your IoT Project

Considering an IoT project but aren't sure where to start? This article takes a look into four factors to keep in mind to kickstart your IoT project.

Read the post
Blogpost preview image v2
Akenza Wins an IoT Breakthrough Award

We are happy to announce that we are the winner of the "Low-Code IoT Platform of the Year" in the 7th annual IoT Breakthrough Awards.

Read the post