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:

mycompany/meetingroom/temperature
mycompany/meetingroom/lamp
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

Akenza product update nov preview
Product update November

This month again, we are excited to bring you new features that will make your life easier. Discover our new asset features and output connectors.

Read the post
Akenza blog azure
Enterprise IoT solutions: get the best of Azure

Learn what makes the combination of akenza and the Microsoft Azure ecosystem such a winning combination to support enterprise IoT solutions.

Read the post
Scale PoC
Enterprise IoT solutions: making the POC scale

This article analyzes what it means to scale a POC to a higher degree of complexity. It explores the challenges an organization faces during the implementation of a large-scale IoT enterprise solution.

Read the post