This article introduces the messaging protocol MQTT, highlighting it's key advantages and introducing how it works.

Message Queuing Telemetry Transport (MQTT) is an ISO standard messaging protocol designed for connecting sensors over unreliable networks. It works on top of the TCP/IP internet protocol.

Two engineers, Andy Stanford-Clark and Arlen Nipper, created the protocol back in 1999. They were developing a system to monitor remote oil pipelines over unreliable satellite networks, and required a messaging system that was low power, easy to implement, and very reliable.

Since its development, MQTT has grown to be a key messaging protocol utilized in many IoT systems and is ideal for home automation, hydroponics, or remote weather stations.

Key Advantages of MQTT


MQTT messages have small bandwidth and are designed to be implemented on low power systems. This makes it ideal for any battery-powered sensors. Using MQTT as a messaging protocol can extend your projects battery life.

Easy Implementation

It is straightforward to implement an MQTT message on your remote sensor system. As most of the complex work is implemented on a central server your remote system can utilize its resources elsewhere.


MQTT is used in mission-critical sensor systems, where it is vital that any message sent is acknowledged and received. MQTT allows you to define how important a message is by declaring its Quality of Service (QOS) level. Using MQTT in your project can give you peace of mind that all your important messages will be received.

Data Agnostic

This protocol allows you to send any type of textual data in a message, numbers, words, even Extensible Mark-up Language (XML) or JavaScript Object Notation (JSON).

How MQTT Works

MQTT works upon a publish/subscribe principle and is comprised of two elements: brokers and clients.

MQTT broker and client table

MQTT comprises two elements: brokers and clients.

At the center of any MQTT system is an application called a broker, which can receive and transmit MQTT messages. When a broker receives a message from a client it can then transmit the message to any other clients that are subscribed to that message topic. A commonly used MQTT broker is Mosquitto, which is available for many platforms such as Windows, Linux or Raspberry Pi. There is even an online broker available which can be used by anyone.

The second component of an MQTT system is a client, which connects to a broker and can publish or subscribe to MQTT messages. For an ESP8266-based project, PubSubClient is frequently utilized as a basis for an MQTT client.

MQTT messages are categorized by a topic which is a string encoded into every message. Clients subscribe to a topic, and when a broker receives a message it will then transmit it to any clients who are subscribed to it. MQTT topics have a similar structure to a file system and use the / character as a delimiter. Some example topics are:

  • home/kitchen/light
  • home/lounge/lamp
  • home/lounge/light

Wildcards (#) can be used to subscribe to all messages on a level. For example, a client subscribed to home/lounge/# will receive both home/lounge/lamp and home/lounge/light messages. A client subscribed to home/# will receive all the above subscriptions.

MQTT Offers an Easy Messaging System

MQTT can offers makers a powerful, easy to implement, and reliable messaging system. It is ideal for any project that requires communicating between devices, such as a home monitoring system, and can be easily adapted to incorporate other sensors at a later stage.

For an example of an MQTT-based system on an ESP8266 client and a Raspberry Pi running a Mosquitto broker, check out How to Install the Mosquitto MQTT Broker on a Raspberry Pi.

Paul Lunn
Dr Paul Lunn is a Lecturer in IOT at Coventry University, UK. He enjoys tinkering with music, programming, Arduino, ESP32, and Raspberry Pi's