The MQTT protocol is a lightweight IoT communication protocol built on the publish/subscribe model and the TCP transport layer, providing a high-reliability data exchange solution for resource-constrained embedded devices in low-bandwidth networks through minimal overhead, flexible topic routing, and three distinct Quality of Service (QoS) levels.
In the embedded field, why does the MQTT protocol occupy an irreplaceable position?
MQTT, full name (Message Queuing Telemetry Transport), is a communication protocol that is not too old. It was originally developed for environments with limited network conditions, so it has the characteristics of low bandwidth and low overhead, and The amount of code is also small, and MQTT itself is built on the TCP protocol, and provides deeper protection for the reliability of information transmission.
Therefore, in the embedded field, the MQTT communication protocol already occupies an irreplaceable part, because most embedded devices require such a protocol for data exchange. There are not many available resources for embedded devices, and various plug-ins The method of connecting to the Internet is also inferior to ordinary mobile phones and personal computers. It is a low-speed communication method, and the large amount of traffic consumption is too much for 4G/NB-IOT devices that consume traffic.

Deep features of MQTT protocol
Next, we should talk about the deep features of the MQTT protocol.
1. One-to-many information release
First of all, it is a protocol based on subscription and publishing, so it can publish messages one-to-many. There are many application scenarios for this function. Limited broadcast allows the server to flexibly control the device it wants to control, and the server can Providing multiple topics that can be subscribed to is extremely critical.
Because for the server, receiving and processing data is the core task. However, as the number of devices and device function lines increases, the server processing logic will increase exponentially. The same data received may be completely uploaded by different types of devices. Different information, so when multiple subscription topics and publishing topics can be provided, this logical difference can be distinguished, which brings great convenience to developers.


2. Different underlying protocols
The second feature of the MQTT protocol is actually that it is based on TCP/IP. It is destined to be a protocol based on the upper layer. Most of the people we come into contact with now are actually developed based on the TCP protocol, but it actually has a version based on UDP. , named MQTT-SN, but everyone knows that TCP is connection-oriented, while UDP is not connection-oriented, so based on different underlying protocol types, the characteristics of MQTT must be different.
For the commonly used MQTT (based on TCP) protocol, it has a very important feature to ensure message reliability: QoS.
QoS is divided into three levels
QoS 0 is actually equivalent to MQTT without additional information protection. Because it is based on the TCP protocol, its message reliability completely depends on the TCP protocol. QoS 1 means that it promises to send it to the recipient at least once. This is information protection at the MQTT layer, not just relying on the TCP protocol layer. Finally, QoS 2 ensures that the message is only delivered to the destination once.
Because for QoS 1, the message may be sent multiple times because there is no feedback, and the receiver may also receive the message multiple times. For this reason, the message transmitted by QoS 2 has a unique ID, and the message with the unique message ID will be stored Twice, first from the sender and then from the receiver QoS level 2 has the highest overhead in the network because two flows are required between the sender and receiver.

At present, the MQTT protocol is actually widely used. It can be found in embedded agriculture, industry, and infrastructure equipment fields, but it is a protocol in itself.
In fact, as a part of data transmission in Internet of Things applications, it plays an equally important role as the wireless transmission method of data. Whether it is 4G wireless module, NB-IOT module, WiFi module, lora module, Bluetooth module, zigbee module, etc., data Transmission belongs to data transmission, but protocols are the soul of the upper layer. Different protocols have different application scenarios and play different roles.
FAQ
Q1: Why do embedded IoT devices prefer MQTT over traditional web protocols like HTTP?
A: Embedded devices, such as sensor nodes, often have limited computational resources and rely on metered connectivity like 4G or NB-IoT. The MQTT protocol is specifically designed for these low-bandwidth, unreliable network conditions. It features an extremely compact packet header and small code footprint, significantly reducing network overhead and power consumption compared to traditional protocols.
Q2: What is the practical advantage of the MQTT "Publish/Subscribe" mechanism for multi-device access?
A: This mechanism decouples the sender from the receiver and enables "one-to-many" message distribution. In complex IoT scenarios where devices upload diverse data types, the server can use different "Topics" to differentiate them. Devices subscribe only to the topics they need, which makes network broadcasting more controllable and greatly simplifies the server's concurrent processing logic.
Q3: How does MQTT ensure messages aren't lost in unstable network environments?
A: Beyond relying on the connection-oriented TCP layer, MQTT provides three levels of Quality of Service (QoS) at the application layer:
-
QoS 0: The message is sent at most once, relying entirely on the underlying TCP (no additional protection).
-
QoS 1: Ensures the message arrives at least once by resending if no acknowledgment is received (may result in duplicates).
-
QoS 2: Ensures the message arrives exactly once through a four-part handshake and unique message IDs, providing the highest reliability at the cost of higher network overhead.