Skip to content Skip to sidebar Skip to footer

What Is MQTT For IOT? How It Works?

MQTT(Message Queuing Telemetry Transport)

What Is MQTT?

What Is MQTT For IOT? - MQTT (Message Queuing Telemetry Transport) is a communications protocol  specifically for "machine to machine". This protocol created by Andy Stanford-Clark (IBM) and Arlen Nipper (Arcom, now Cirrus Link) in 1999.

MQTT was originally created for the Embedded System where this protocol is designed with the ability to send and receive data which is relatively lighter than the HTTP protocol.

Because of the advantages of this protocol, it is currently widely used in Embedded Systems for the Internet of Things for use on top of the TCP/IP Protokol.

What is Protocol?

Protocol is a set of rules that must be followed by 2 objects that want to exchange communication. another word for protocol is communication language

For example, two people use English when speaking, then communication can run smoothly.

But if one person speaks in English and the other person speaks in French, then the communication between the objects will be chaotic.

Therefore, a machine-to-machine communication language is needed so that the machine can communicate with other machines, which is called a protocol.

What are the advantages of MQTT?

  • MQTT runs at the TCP/IP layer
  • MQTT is Faster than HTTP
  • MQTT is more efficient for sending small data, for example (text. commands or others) but not efficient for sending large data such as images and videos.
  • MQTT requires very little power and bandwidth to transmit data
  • MQTT can be bidirectional
  • MQTT can run well even though the network is unstable
  • MQTT can send data in Text, XML, JSON and other formats.

How Does MQTT Work?

MQTT which is a communication protocol has 4 important components to work:

1. Publisher

The publisher is the sender. Where is the device that acts as a data sender.

2. Broker

Brokers have the function of channeling data sent by Publishers (senders) to Subscribers (recipients), generally on a hosting (cloud). Therefore, publishers must send data to brokers via the internet.

3. Subscriber

Subscribers are recipients. Where its function is to receive data from the broker.

4. Topic

Topic can be called a communication ID with a UTF-8 string and Case Sensitive. If the TOPIC in the Publisher is the same as the Subscriber, then the data will be sent and received properly by the Subscriber.

A working illustration of an MQTT Protocol is as follows:

What Is MQTT For IOT? How It Works?
MQTT Publish / Subscribe Architecture (by

Qos (Quality of Service)

In MQTT there is what is called QoS or the level of quality of message delivery services. There are 3 levels of QoS in MQTT namely Level0, Level 1 and Level2.

  • QoS Level 0 (at most once delivery) i.e. the message is only sent once by the publisher and the publisher does not need a response back whether the data was successfully sent or not. So at this level the sender cannot know whether the message sent was successful or not.
  • QoS Level 1 (at least once delivery) is a message sent at least once, if the subscriber does not receive a message, the broker will send a response to the publisher that the message failed to send. With QoS level 1, message duplication can occur due to repeated message sending.
  • QoS Level 2 (exacly once delivery) ie messages are sent once and only once. This level 2 QoS re-assures that the message has been received by the subscriber, thereby preventing message duplication.

Hopefully this article is useful. To be able to understand how MQTT works, I will practice directly using the NodeMCU ESP8266, because the microcontroller module has a built-in WiFi feature, we can easily connect to the Internet.

Post a Comment for "What Is MQTT For IOT? How It Works?"