How MQTT Protocol Works
- Rahul Singh

- Apr 23, 2018
- 2 min read
Why we need MQTT :
Minimizing power consumption is a huge driving force in the Internet of Things since a vast majority of it relies on wireless, battery-powered embedded devices. In addition to creating chips and peripherals that use less and less power, it's also important to focus on wireless protocols that maximize reliability while also minimizing computational overhead and transceiver power.
The data from an IoT sensor generally isn't presented to a user directly, so they rely on machine-to-machine (M2M) communication protocols to get the data to a point where it can be processed and used in a meaningful way. One very commonly used M2M protocol used by IoT devices is called MQTT (Message Queuing Telemetry Transport).

The MQTT protocol uses a publish/subscribe communications model which allows for data to be sent and received asynchronously. A web service called a broker manages where the data is coming from and going to.

As an example for IoT applications, a wireless thermometer client (Sensor in this case) can publish temperature data (message) to a topic called /sensors/temp and a humidity sensor client could publish its data to /sensors/humid. Our broker then gets these data and send them to the devices subscribed to that particular topics.
We can subscribe (for listening) to multiple topics and can publish (sending) data to any topic without subscribing.i.e, we don't need to subscribe for publishing (sending) data but need to subscribe when listening for data of particular topic.
A working example of MQTT :

NOTE :
We can publish data on multiple topics.
We can subscribe to multiple topics and then get message published (by client or sensor) on each topic.
Two or more devices can subscribe to the same topic (Receiving data for each topic).
Two or more devices can publish to the same topics. (sending data to each topic).
The functions of a broker :
Store and forward data (messages).
filtration of messages.
Prioritisation of messages.
One of the best example of the broker is "Mosquitto" by Eclipse.









Comments