Learn MQTT in 3 easy steps?


In this blog you will learn MQTT(Message Queue Telemetry Transport) in 3 easy steps which are WHAT, WHY AND HOW. Here are the topics that we will cover in this blog post,

  • What is MQTT or Message Queue Telemetry Transport?
  • Why Message Queue Telemetry Transport?
  • What are the types of Quality of Services?
  • Working of Message Queue Telemetry Transport
  • Importance of MQTT
  • Applications

What is MQTT?

MQTT or Message Queue Telemetry Transport is an OASIS standard messaging protocol for Internet of Things(IoT). It is designed as an extremely lightweight publish/subscribe messaging transport that is ideal for connecting remote devices with a small code footprint and minimal network bandwidth. MQTT today is used in a wide variety of industries, such as automotive, manufacturing, telecommunications, oil and gas, etc. 


Lightweight and Efficient

MQTT clients are very small, require minimal resources so can be used on small microcontrollers. MQTT message headers are small to optimize network bandwidth.

Bi-directional Communications

MQTT allows for messaging between device to cloud and cloud to device. This makes for easy broadcasting messages to groups of things.

Scale to Millions of Things

MQTT can scale to connect with millions of IoT devices.

Reliable Message Delivery

Reliability of message delivery is important for many IoT use cases. This is why MQTT has 3 defined quality of service levels: 0 – at most once, 1- at least once, 2 – exactly once.

There are three types of quality of services:

  1. QoS0: This provides the lowest level of service and this is so because in this mode sender doesn’t acknowledge whether the recipient receiver the message or not. The terms used to describe this strategy are “Fire and forget” or “at the very most once distribution” .
  2. QoS1: This broker tries to send the message and then checks for the user’s approval reply. When no verification is received in a certain amount of time, the message is resent. If the broker does not get the user’s confirmation on time, the message may be sent to the user multiple times using this approach. “At least once delivery” is a term used to describe this.
  3. QoS2: A four-step handshake is used by the client and broker to ensure that information is received and only once. This is referred to as “exactly once delivery” on occasion. QoS 0 may be the optimal option when communications are reliable but constrained. QoS 2 is the optimum solution in cases where communications are inconsistent but links aren’t as resource-constrained. 

Support for Unreliable Networks

Many IoT devices connect over unreliable cellular networks. MQTT’s support for persistent sessions reduces the time to reconnect the client with the broker.

Security Enabled

MQTT makes it easy to encrypt messages using TLS and authenticate clients using modern authentication protocols, such as OAuth.

Working of MQTT

Working of MQTT

In the image above you can see that 3 terms are used which are publisher, subscriber and broker(which here is given as mqtt). Now let’s understand that what exactly these three are and what are they used for.

Let’s understand this with an example: let say you have subscribed to my YouTube channel so you are the subscriber and I become the publisher. So what does that mean, it means if you are a subscriber then you are expecting some inputs(which refers to the content that I upload on my channel) to be given to you from my end and I am the publisher so that means I’ll upload the content on my channel to help to enhance your knowledge and skillset. But we both(publisher and subscriber) are not connected directly to each other, instead we are using a broker (platform named YouTube) to communicate with each other.

In the similar way, here MQTT is the broker and our smartphone and sensors act as a publisher and subscriber. As per the above image we have 2 publishers(publisher 1 and publisher 2) and 3 subscribers(subscriber1, subscriber2 and subscriber3). Here publisher1 is device connected to the soil moisture sensor which senses the moisture content in the soil and publish(send moisture values to broker) it. Further, broker send back the moisture values to the subscribers connected, who are subscriber 1 and subscriber 2.

Now, that we have the moisture values of the field we can further react to it by turning ON/OFF the water pump(which is connected to subscriber3), but this subscriber will receive the signal from the broker only when the publisher2 will send a request to turn it ON/OFF. So, this is the way how does the MQTT protocol works and we get a real-time control over the IoT products.

Importance of MQTT

The most important reasons why Message Queue Telemetry Transport is required in IoT are:

  • It drives Efficiency
  • It unlocks remote sensing and control
  • It consumes less power
  • It facilitates efficient data dissemination
  • It delivers message in a timely and efficient manner


Here is the list of applications of MQTT:

  • Remote sensing
  • Smart cities
  • Social media platforms 
  • Home automation 
  • Smart farming 
  • Wearables 
  • Manufacturing 
  • Oil and gas industry

Time to wrap up now. Hope you liked our content on What is MQTT or Message Queue Telemetry Transport. See you in our next blog, thanks for reading our blog and do leave a comment below to help us improve the content to serve you all of our experience with you. Stay tuned with us for more python contents.

Also check out our other playlist Rasa ChatbotInternet of thingsDockerPython Programming, etc.
Become a member of our social family on youtube here.

Stay tuned and Happy Learning.