
What is IoT and Why IoT:
IoT is a network of physical devices like home appliances, sensors, etc which can be connected and used to exchange data with each other. Basically, it’s a giant network of connected devices – all of which collect and share data about the way they are used and about the environment around them.This can be anything like smart microwaves which can automate cooking, self-driving cars, etc. It enables devices/objects (thing) to observe, identify and understand a situation without human help and perform a task based on the situation. Some of its advantages include more data, tracking, time and money. We have seen in detail about the IoT in one of our blogs.
What is Thing:
A ‘thing’ is a term commonly used which refers to a physical device connected to the internet. It can be a mobile device connected to the internet.
Now we will see in detail about the MQTT protocol which is a lightweight protocol used to facilitate IoT in a device.
MQTT – Protocol for IoT:
MQTT (Message Queue Telemetry Transport) protocol complements the necessities of IoT. It is a lightweight protocol designed for publish/subscribe messaging transport. It requires very low bandwidth and has less battery consumption. It can be used in small sensors, home automation devices, etc. Facebook also uses this protocol. https://www.facebook.com/notes/facebook-engineering/building-facebook-messenger/10150259350998920
It is high-level architecture with 2 main parts – (broker and a client)
Broker:
A broker does the important job with capabilities for both subscribing and publishing. Its primary function is to queue the received messages from the publisher and transmit the messages received to the subscriber client accordingly.
Client:
MQTT client does very simplified tasks as most of the major handling is done by the broker. They can be run on almost any operating System ranging from Mac, Windows to mobile OS like Android and iOS. The publisher client publishes messages using a TOPIC and QOS. Similarly, a subscriber client subscribes to messages with a TOPIC and QOS.
Topic:
Every transmission over the network relies on a particular topic. It is nothing but a path where you can publish/subscribe messages. For e.g.: Consider an app connected using MQTT sending current location of the user to the topic like “AppName/Location”. If a client is subscribed to the same topic as said above, they can continuously track the user’s location. If you want to track user app’s battery status apart from tracking the location, then the topic can be configured something like “AppName/UserID/Location” for location tracking and “AppName/UserID/BatteryStatus” where userID mentions the corresponding user. There are two wild card operators “+” and “#” involved here. “+” is used where the client receives all arbitrary messages up to one hierarchy while “#” allows messages to be received from all below hierarchy levels. Eg:- When a client is subscribing to topic like “AppName/+/BatteryStatus”, it will receive battery status from all user. And subscribing to “AppName/userID/#”, it will receive all messages like battery status and location of that corresponding userID.
QOS:
It stands for Quality of Service. There are basically three types.
QoS – 0: This does not guarantee if a message has been delivered successfully. It is like “fire and forget” type.
QoS – 1: This guarantees the message will be delivered at least once. But can be sent more than once.
QoS – 2: This guarantees that the message is sent only once.
The higher the QoS, the higher it consumes bandwidth to process the transmission.
Conclusion:
Thus we have seen in detail in about the principles of MQTT protocol for IoT. In the future blogs, we will see how the process is done in detail with a sample program for a better understanding.
–
Rajtharan G,
iOS Team,
Mallow Technologies.