What is MQTT Protocol?
MQTT (Message Queuing Telemetry Transport) is a lightweight publish/subscribe messaging protocol running over TCP, designed for networks with limited bandwidth or unstable connections. It was developed in 1999 to monitor oil pipelines over satellite links and is now an OASIS standard (common versions are 3.1.1 and 5.0).
How does MQTT work?
Unlike the request/response model of Modbus, devices that produce and consume data in MQTT do not know each other. A broker (server) in the middle handles all traffic:
- A publisher publishes a message to a topic.
- A subscriber subscribes to the topics it cares about.
- The broker forwards each message to everyone subscribed to that topic.
The default port is 1883 for plain connections and 8883 with TLS. The fixed header is as small as 2 bytes, so overhead on small sensor messages is low.
Example: topic structure and QoS
Consider a gateway publishing weighing data from a plant:
- Topic:
konya-plant/line1/scale1/weight - Payload:
{"value": 1250.4, "unit": "kg", "ts": "2026-11-23T10:15:00Z"}
Subscribers can use two wildcards:
konya-plant/line1/+/weight→ the weight of every scale on line 1 (+is a single level).konya-plant/line1/#→ everything on line 1 (#is multi-level, only at the end).
| QoS | Guarantee | Overhead | When |
|---|---|---|---|
| 0 | At most once (may be lost) | Lowest | Frequent readings where a lost sample does not matter |
| 1 | At least once (may duplicate) | Medium | Most telemetry and alarms |
| 2 | Exactly once | Highest (4-step handshake) | Counters, commands where duplicates are harmful |
Other key features
- Retained message: the broker stores the last value on a topic; a new subscriber gets the current state immediately.
- Last Will (LWT): if a client disconnects unexpectedly, the broker publishes a predefined message (e.g.
status = offline). - Keep-alive and persistent session: QoS 1/2 messages can be queued in a persistent session while a client is offline.
Common mistakes
- Starting a topic with
/: it creates an empty level and confuses subscription matching. - Using QoS 2 everywhere: it adds traffic and latency for no benefit.
- Two devices with the same Client ID: the broker drops one, and the devices keep kicking each other off.
- A broker without authentication or TLS: an internet-facing port 1883 is a serious security hole.
- Subscribing to
#: in large systems it floods the client with data it does not need.
Where is it used in industry?
It has become the standard way to move values read from field Modbus devices to the cloud, SCADA or a database. In a typical architecture a gateway polls RS-485 Modbus devices such as the Amazeng ZMA and publishes the values over MQTT. For more see the IoT entry, our industrial data collection with AWS IoT Core post and our cloud IoT data collection solution.
Related Terms
- What is IoT (Industrial Internet of Things)?What IoT and IIoT are: device, gateway, connectivity and cloud layers, a Modbus-to-MQTT data path, a data volume calculation and common mistakes.
- What is Modbus RTU and Modbus TCP?How Modbus RTU and Modbus TCP work: RS-485 framing, function codes, CRC, the MBAP header, port 502 and the most common mistakes in the field.
- What are LoRa and LoRaWAN?LoRa vs LoRaWAN: chirp modulation, spreading factor, the EU868 band, a duty cycle calculation, device classes A/B/C, OTAA and common field mistakes.
- Wi-Fi Usage in Industry: Pros and ConsIndustrial Wi-Fi: IEEE 802.11 generations, 2.4/5 GHz channel planning, roaming (802.11r/k/v), WPA3 security, common field mistakes and the right use cases.