MQTT Explained: The Lightweight Language of Connected Devices

MQTT explained in plain terms means a tiny messaging protocol that lets small devices, such as sensors, thermostats, and trackers, send short messages to each other over unreliable networks. The central question is why devices need their own language at all, and the short answer is frugality: a sensor running on a battery cannot afford the heavy conversation of the ordinary web.

Think of a village noticeboard instead of a telephone exchange. Nobody calls anyone directly; messages are pinned under a heading, and anyone interested in that heading reads them. MQTT works the same way, with topics instead of headings, and a broker instead of a board.

MQTT stands for Message Queuing Telemetry Transport, and it was invented in 1999 by engineers at IBM who needed to monitor oil pipelines over satellite links. It became an open standard in 2013 and is now the quiet backbone of the Internet of Things, carrying messages for homes, factories, and vehicles.

Key takeaways

  • MQTT is a lightweight publish-and-subscribe messaging protocol for small devices.
  • Devices publish messages to topics; interested devices subscribe to them.
  • A central broker receives every message and delivers it to subscribers.
  • It uses very little bandwidth, battery, and processing power.
  • It suits sensors, smart homes, vehicles, and industrial monitoring.

What MQTT is

MQTT is a messaging protocol designed for devices that are small, remote, and connected by networks that drop out. It runs over the same TCP connections as the web, but its messages are tiny, often just a few bytes, and its rules are simple enough for a microcontroller with almost no memory to follow.

The pattern is publish and subscribe. A device that has news, a temperature reading, a door opening, a tank level, publishes a message to a named topic, such as home/kitchen/temperature. Any device or application that has subscribed to that topic receives the message. Publishers and subscribers never talk to each other directly, and neither needs to know the other exists.

Between them sits the broker, a server that receives every published message and passes it on to the subscribers of its topic. The broker also holds messages for subscribers that are temporarily offline, depending on the settings, and it manages who is allowed to publish or subscribe to which topics.

MQTT offers three levels of delivery promise, called quality of service. At the lowest, a message is sent once and may be lost. In the middle, it is delivered at least once, with a possible duplicate. At the highest, it is delivered exactly once, with the extra handshaking that guarantee requires. A device chooses the level each message needs, trading reliability against effort. Our guide to the Internet of Things explains the world of connected devices that MQTT was built to serve, and why their networks need a protocol this light.

How MQTT works

It begins with a connection. A device opens a TCP connection to the broker and stays connected, often for hours or days, sending a small keep-alive message now and then so the broker knows it is still there. That single long-lived connection replaces the repeated connect-and-disconnect dance of ordinary web requests, which is where much of the saving comes from.

When a sensor has data, it publishes a message: a topic name, a small payload, and a quality-of-service level. The broker receives it, looks up which clients are subscribed to that topic, including wildcard subscriptions that cover whole branches of the topic tree, and forwards a copy to each one.

Subscribers do the reverse. An application that wants temperature readings subscribes to home/kitchen/temperature, and from then on the broker pushes every matching message to it as soon as it arrives. There is no polling, no asking again and again: the data arrives the moment it exists.

The broker can also remember the last message on a topic, called a retained message, so that a device joining late still gets the current value immediately, instead of waiting for the next reading. Combined with a last will message, a note the broker publishes automatically if a device disconnects unexpectedly, MQTT gives a system a simple way to know what is happening and what has gone quiet. Our guide to 5G explains the mobile networks that increasingly carry these messages, where low latency and huge device counts are exactly what MQTT was designed for.

A photograph of a dark room at night with a small sensor device glowing green on a table, a laptop showing message topics behind it
MQTT is a noticeboard, not a telephone: devices pin short messages to topics, and the broker delivers them to whoever is listening.

Comparing MQTT with HTTP for devices

Aspect HTTP MQTT
Connection pattern Connect, ask, disconnect, repeat One long connection, messages pushed
Message size Large, headers on every request Tiny, a few bytes of overhead
Who starts the exchange The client, by polling Either side, the moment data exists
Power and bandwidth Heavy, wastes both Minimal, built for batteries
Best for Web pages and APIs Sensors and small devices

Where MQTT is used

Smart homes are the most familiar use. A thermostat publishes the temperature, a motion sensor publishes movement, and a hub subscribes to both, deciding when to heat a room or switch on a light. The messages are small and frequent, and the network is a home connection that nobody wants to saturate.

Industry uses it at far larger scale. Factories publish readings from thousands of machines, vibration, temperature, pressure, and a monitoring system subscribes to the topics it cares about, raising alarms when a value drifts. The same pattern watches pipelines, power grids, and water systems across whole countries.

Vehicles and fleets rely on it too. A delivery van publishes its position and fuel level every few seconds, and the dispatch system follows the whole fleet in real time, over mobile networks that come and go as the van moves. MQTT’s tolerance for dropping connections is what makes that work.

It also appears in messaging apps and notifications. Some chat systems use MQTT behind the scenes to push messages to phones, because a single lightweight connection drains far less battery than repeatedly asking a server whether anything is new.

Strengths and limits

The greatest strength of MQTT is how little it asks of a device. A sensor with a tiny processor and a coin battery can run it for years, sending readings over a flaky connection, and the broker does the heavy work of routing and delivery. Its simplicity also makes it easy to reason about: topics, publishers, subscribers, and one broker.

It scales well, too. A broker can serve tens of thousands of connected devices, and brokers can be clustered when one is not enough. The topic tree gives a system a natural structure, so adding a new sensor is as simple as publishing to a new topic name.

Its limits start with security. Early MQTT had no encryption or authentication built in, and many deployments still run it bare on private networks. Modern practice adds TLS encryption and username-and-password or certificate authentication, but the protocol itself does not force it, and careless deployments are a real risk.

It is also a poor fit for large payloads or request-and-response conversations. MQTT moves small messages one way, from publisher to subscriber, and it has no built-in way to ask a question and wait for an answer. For big files or complex APIs, other protocols are the right tool.

MQTT checklist

  • Design topic names as a clear hierarchy, such as site/area/device/reading.
  • Choose the quality-of-service level each message really needs.
  • Always use TLS encryption and authentication on the broker.
  • Set retained messages so new subscribers get current values at once.
  • Use last-will messages so the system knows when a device goes quiet.
  • Keep payloads small and simple, ideally plain text or compact JSON.
  • Plan for the broker as a single point of failure: cluster or back it up.
  • Monitor connected clients and dropped messages, not just the data.
  • Test with flaky networks: devices must reconnect cleanly on their own.

Frequently asked questions

What is MQTT?

MQTT is a lightweight messaging protocol for small devices. Devices publish short messages to named topics, and a central broker delivers them to every device or application subscribed to those topics.

What is an MQTT broker?

The broker is the server in the middle. It receives every published message and forwards it to the subscribers of that topic, and it can hold messages for offline clients and remember the latest value on each topic.

What are MQTT topics?

Topics are named channels, written like paths, such as home/kitchen/temperature. Publishers send to a topic, subscribers listen to one, and wildcards let a subscriber follow whole branches of the topic tree at once.

How is MQTT different from HTTP?

HTTP is request and response: a client asks, a server answers, and the connection closes. MQTT keeps one connection open and pushes messages the moment they exist, with far less overhead, which suits battery-powered devices.

Is MQTT secure?

It can be, but not by default. Use TLS to encrypt the connection and authentication to control who may publish and subscribe. An open broker on the public internet is a genuine security risk.

When should I not use MQTT?

For large files, complex request-and-response APIs, or work that needs a direct answer. MQTT is built for small, one-way messages, and other protocols serve those jobs better.

The bottom line

MQTT explained in one line is this: a tiny, thrifty noticeboard for machines, where devices pin short messages to topics and the broker makes sure the right listeners see them.

Use it wherever small devices must talk over unreliable networks, keep the broker secured and the topics tidy, and thousands of sensors can report faithfully for years on a single battery. For the Internet of Things, it remains the default language.

This article is general information about how MQTT works, not advice about how to design messaging for a particular system.

Latest articles

Scroll to Top