Explanation, Advantages & Use Cases

What is MQTT?

MQTT is a robust network protocol for exchanging data between machines, devices and other applications. It is based on a publish-subscribe model and has established itself as one of the most important protocols for the Internet of Things (IoT). MQTT is widely used in areas such as industrial manufacturing and home automation.

Explanation

How does MQTT work?

MQTT is an open and resource-efficient network protocol for exchanging messages between devices, machines and other systems. Due to its reliability, it has established itself as one of the most important protocols for the Internet of Things (IoT). In the OSI model, MQTT is located at the application layer.

At the center of MQTT communication is the MQTT broker.

MQTT clients send messages linked to a specific topic to the MQTT broker. The broker in turn automatically forwards these messages to all clients that have subscribed to the respective topic. The MQTT broker thus acts as a middleman between the MQTT clients.

This publish-subscribe mechanism has an important advantage: The powerful MQTT broker, which is often operated in the cloud, manages sessions and data, while the participating client devices only receive the requested messages. This means that smaller, less powerful devices such as sensors, embedded devices and industrial controllers are able to participate in MQTT communication.

MQTT also defines certain mechanisms for dealing with connection interruptions (see „How does MQTT handle connection loss?“).

MQTT communication explained

In general, data exchange via MQTT works as follows:

1. Devices or other applications transmit messages to an MQTT broker (also called MQTT server). These messages contain a topic. MQTT clients that publish messages via the MQTT broker like this are also referred to as publishers.

2. Devices or other applications subscribe to selected topics via the MQTT broker. The broker automatically sends new messages about a topic to clients that have subscribed to this topic (subscribers).

Different MQTT clients therefore never communicate directly with each other, but always via a central broker.

An MQTT broker is not a database and does not normally store any previous messages relating to a topic. However, with the help of so-called “retained messages”, selected messages can be permanently saved and automatically transmitted to new subscribers of a topic.

What is an MQTT broker?

An MQTT broker is a server that is often operated in the cloud. It handles the distribution of messages to the MQTT clients. To do this, it must save the client sessions, i.e. which clients have subscribed to which topics.

What is an MQTT client?

An MQTT client can act as both a publisher and a subscriber. A subscriber client receives new messages for one or more topics to which it has subscribed. A publisher client publishes messages on a topic, which are then forwarded to the subscribers by the broker. Strictly speaking, the MQTT client is a small program that is installed on a sensor, computer or other device and enables the MQTT functionality.

What are MQTT topics?

Each MQTT message is assigned to a specific topic. The MQTT broker organizes topics and the associated messages in a hierarchical structure that is similar to a file system on a PC.

An MQTT topic could be structured like this:

ProductionSite/ProductionLine/Machine/Parameter

Clients can subscribe to any hierarchy level of a topic.

What is the MQTT payload?

The MQTT payload is the actual content of an MQTT message. In addition to this content, a topic and a quality of service (QoS) level must be specified for each message.

What is the Quality of Service (QoS)?

The Quality of Service (QoS) of an MQTT message defines how often the message is sent to the subscribers of a topic.

The following QoS are possible:

“At most once” (0): The message is only sent once and there is no confirmation of successful delivery.

“At least once” (1): The message is sent repeatedly until a confirmation of delivery is received.

“Exactly once” (2): An exchange between client and broker ensures that the message is delivered exactly once. This is the most reliable QoS, but requires multiple data transmissions between client and broker and is therefore also the most resource-intensive.

How does MQTT handle connection loss?

If the connection of a publisher client to the broker is unexpectedly interrupted, a so-called “Last Will” message can be sent to the broker for a specific topic. This can be used to notify subscribers to the topic that the client is no longer available.

If the subscriber of a topic cannot be reached, messages can be temporarily stored by the broker and sent at a later time.

Which security measures does MQTT implement?

The authorizations of MQTT clients are managed by the broker. Here you can specify which clients can access which topics. It is also common for clients to have to authenticate themselves to the broker with a user name and password.

The transmitted data is usually encrypted using TLS.

Advantages

What are the advantages of MQTT?

Data exchange via MQTT offers key advantages for IoT communication – especially when smaller devices or limited network resources are involved.

Low network utilization:
MQTT is a lightweight and efficient protocol. Data packets (headers) are lean as MQTT uses a binary message format (HTTP, for example, uses a text-based message format).

Communication over unstable networks:
Due to the low network utilization (see above) and the mechanisms for dealing with connection failures, MQTT is well suited for data exchange in unreliable networks.

Low demands on device resources:
The lean data packets, the distributed client-server structure and the options for handling connection failures enable reliable data exchange with low-resource devices such as sensors.

Scalability:
Since message exchange via MQTT takes place via a central broker, additional devices can be integrated as clients at any time. MQTT brokers themselves are often located in the cloud and thus offer high performance.

Security:
MQTT supports both the authentication of communication participants and encryption mechanisms such as TLS.

Simplicity:
Especially on the client side, MQTT is very easy to implement and use.

Use cases

Where is MQTT used?

The use cases for MQTT are extremely diverse. Communication via MQTT is characterized by its low network load and low resource requirements for the devices involved (see also “What are the advantages of MQTT?”). As a result, MQTT is used in situations where smaller devices need to exchange data reliably. MQTT has been established as one of the most important protocols for the Internet of Things (IoT), Industrial Internet of Things (IIoT) and edge computing.

In many cases, MQTT is used to transfer data between devices and cloud platforms. Cloud environments such as Microsoft Azure and Amazon Web Services integrate their own MQTT brokers to process MQTT data from IoT devices.

The most important areas of application for MQTT include the following:

  • Industrial production: Data exchange with production systems (see also edge computing)
  • Logistics: Tracking of goods and stock levels
  • Healthcare: Communication with medical devices
  • Energy supply: Monitoring of energy consumption and power grid components
  • Vehicle networking: Monitoring of vehicles and communication with traffic systems
  • Financial services: Real-time data feeds and communication between trading platforms
  • Agriculture: Monitoring of equipment, watering systems and environmental conditions
  • Security: Use in surveillance cameras and alarm systems

MQTT is particularly suitable for environments in which edge computing and cloud computing are combined. Data from edge devices can be transmitted to central cloud platforms using MQTT.

MQTT for industrial production

MQTT communication with manubes

manubes, our cloud platform for digital production management, uses MQTT to communicate with industrial machines, devices and cloud platforms.

manubes can be connected to an MQTT broker as a subscriber and thus gain access to a wide variety of data sources – including sensors, controllers and other devices. Within manubes, this data can not only be stored and structured in the form of data models, but also visualized interactively and in real-time.

As a publisher, manubes is able to send data to cloud platforms such as Microsoft Azure, which integrate an MQTT broker.

The use cases mentioned above and many other scenarios can be implemented as part of automated workflows. Together, the manubes features enable the development and management of comprehensive industrial applications on a no-code basis (Citizen Development).

Digital production management in the cloud

With manubes, you are able to systematically automate production processes and visualize all areas of a production in real time.

The manubes platform offers worldwide access via web browser, easy operation and maximum security for production data.

Discover manubes!

Cloud-based production management with manubes: Our innovative platform offers specialized tools for connecting production systems, managing and visualizing production data and automating production processes. manubes users benefit from a powerful infrastructure, worldwide access and maximum security.