The principle of publish and subscribe is the heart of MQTT. Devices can publish messages (for example, on) to a channel that can be freely defined; for example, /living-room/my-custom-coffee-machine.
Other devices that are connected to the same MQTT server can subscribe to this channel, resulting in near instant updates, whenever there is a new message published to that particular channel.
The MQTT server connects all of the publishers and subscribers, and keeps track of the subscriptions for each client. Every client only receives what it is subscribed to:
Three devices connected to an MQTT server
All devices are connected to the MQTT server (in the middle). It forwards the published messages to the subscribers.
Sometimes, publish and subscribe is referred to as pub/sub. One of the earliest MQTT clients for Arduino is...