MQTT
(MQTT)
A lightweight messaging protocol using the publish/subscribe model through a broker, very common in IoT.
Educational content in scientific-draft form; a specialist should review it before it is adopted as an academic reference. No measurement or performance result that was not actually obtained is shown here.
Protocol card
| Transport | TCP (usually) |
|---|---|
| Range | Depends on the underlying network |
| Data rate | Depends on the underlying network |
| Power consumption | Relatively low overhead |
| Topology | A star around a broker |
How it works
Clients publish messages to topics at a broker that distributes them to subscribers, with quality-of-service levels and retain and will options.
Security
Supports authentication and TLS encryption at the broker; security is not automatic.
Role in AIoT
The most common transport channel between nodes, gateways and the cloud.
Use cases
- Sensor readings
- Commands to actuators
Advantages
- Light on devices
- Decouples the sender from the receiver
- Suits unstable networks
Limitations
- The broker is a central point
- Does not define the payload structure
Code example
import paho.mqtt.client as mqtt
client = mqtt.Client() # see the paho-mqtt documentation for the version you use
client.connect("localhost", 1883)
client.publish("farm/field1/soil/moisture", "42")
client.disconnect()Official links
Official external links open in a new window; they were not checked automatically, so if a page address changes, go back to the official organisation's site.
Simulations and labs run inside your browser. Nothing you enter and none of the conversations is stored on the server. Privacy policy
