What is MQTT and How MQTT Works?
In the current world of technology, you must have heard the word 'IoT'.
The Internet of Things abbreviated as IoT is a network of physical objects that exchange data with other devices over the Internet.
The data is shared through software and other technologies.
The standard of IoT messaging is MQTT, Message Queuing Telemetry Transport. Many people may ask what is MQTT and how MQTT works？
In this article, I will tell you what MQTT is, why MQTT is important and some use cases of MQTT.
So, let's start.
1. What is MQTT - Definition
MQTT is an open OASIS and ISO (ISO/IEC 20922) standard lightweight messaging protocol. It is a publish/subscribe network protocol that transports messages between devices. In 1999, there was requirement for connecting Oil Pipeline telemetry system over satellite so MQTT was designed by Andy Stanford-Clark (IBM) and Arlen Nipper. It is ideal for connecting remote devices with minimal network bandwidth, handles unreliable networks, easily implemented, and is, therefore, ideal for machine-to-machine (M2M) communication. This protocol runs over TCP/IP. MQTT is used in several industries including automotive, logistics, consumer products, telecommunications, oil and gas, etc.
2. How MQTT Works?
The MQTT protocol has two subjects: a client and a broker. Server is the MQTT broker whereas connected devices are clients. When the client wants to send data to a broker, it is called publish. When the broker wants to send data to the client, it is called subscribe.
Let's take the example of a temperature sensor device. It wants to send its readings to the broker which is a phone or desktop application. A phone or desktop application looks forward to receive this temperature value. Therefore, there will be two-way communication:
- The temperature device defines the place it wants to publish on, ex: “temp". It publishes the message “temperature value”.
- The application subscribes to the topic “temp”. It then receives the temperature value.
In case of a broken connection between the subscribing client and broker, the broker will buffer messages and push them out to the subscriber when it is back online. But if the case is of publishing client and the broker, and the connection is disconnected without being noticed then the broker sends subscribers a cached message with instructions from the publisher.
3. What is MQTT - Why MQTT?
· LIGHTWEIGHT AND EFFICIENT
MQTT clients are very small and require minimal resources so can be used on small microcontrollers. MQTT has a small code footprint therefore it optimizes network bandwidth.
· BI-DIRECTIONAL COMMUNICATIONS
MQTT allows for messaging between the device-to-cloud and cloud-to-device. This feature makes broadcasting messages easily to groups of things and efficient distribution of data.
· SCALE TO MILLIONS OF THINGS
MQTT has the ISO standard of message which enables it to connect with millions of IoT devices.
· RELIABLE MESSAGE DELIVERY
The reliability of message delivery is important for many IoT use cases. This is why MQTT has 3 defined qualities of service levels:
- At most once – A message is sent once and only once. No follow-up done to confirm if the client has received the message or not.
- At least once – After a message is sent, the client sends a response to acknowledge that the message has been received. The broker will continue to resend the message until an acknowledgment is received.
- Exactly once – The broker and client confirms that the message is received and only delivered once.
· SUPPORT FOR UNRELIABLE NETWORKS
Many IoT devices connect over unreliable cellular networks. MQTT has persistent sessions that reduce the time to reconnect the client with the broker.
· SECURITY ENABLED
MQTT uses TLS/SSL to encrypt messages and modern authentication protocols.
· MQTT uses minimized data packets that results in low network usage
· MQTT uses small amounts of power, which is good for the connected devices
4. What is MQTT - Use Cases of MQTT
BMW Mobility Services (Car-sharing application) has been using HiveMQ and MQTT for over 4 years. The HiveMQ enables more than 80,000 concurrent connected software clients and generates over 90,000 messages per minute. BMW Mobility Services use HiveMQ to function as an internal messaging bus that moves data between back-end micro services.
Matternet is building drones to reduce the time it takes to transport medical samples between hospitals and testing laboratories. By using HiveMQ, Matternet tracks real-time flight status. MQTT messages are transmitted through HiveMQ running on the Matternet platform. The messages are sent between drones and to landing stations during flights.
MQTTRoute, a platform for transmitting messages is used by Celikler Holding to monitor power generation from multiple power plants. The use of MQTT provided secure communication between power plants.
· CONSUMER PRODUCTS
CASO Design creates Smart Kitchen Appliances. For instance, CASCO WineComfort Smart, a wine cooler guarantees to save the quality of wines. The App monitors and reports any error messages in a matter of seconds, for instance if there is any change in temperature, you will be notified. In this way, it ensures wines are stored in the right conditions.
· SOCIAL MEDIA
Facebook uses MQTT for its Messenger app. The protocol saves battery power during mobile phone-to-phone messaging. Also, despite inconsistent internet connection, the protocol enables messages to be delivered efficiently in milliseconds.
If you are looking to buy converters to enable machine-to-machine (M2M) communication then you can visit USR IOT. The serial to Ethernet converters makes it easy to put electronic equipment on an Ethernet network making M2M communication possible in various applications by enabling client access independent of any operating system or proprietary protocol. Also, you don't need any intermediate host PCs and software programming to let the devices communicate with each other.