🔌MQTT Protocol
Also known as MQTT, MQTT Broker, Mosquitto, MQTT Topic
A small way for devices to send messages. They post to a topic on a broker.
Think of it like
It is like a notice board. Devices pin notes under a topic. All who follow it get a copy.
Example
Lucy's greenhouse sensor publishes to the topic greenhouse/temp. Her phone app and the fan both subscribe, so both get each reading.
Why it matters
Its messages are tiny, so it works on weak links and small chips. Adding a new listener needs no change to the sensor.
Definition
Example code
console
$ mosquitto_pub -h localhost -t greenhouse/temp -m 24.5
$ mosquitto_sub -h localhost -t greenhouse/temp
24.5Common mistake
Key takeaways
- 1Broker in the middle. Devices never talk straight.
- 2Topics. Messages go under a name.
- 3Small messages. Built for weak links.