MQTT for IoT defines three QoS levels for message delivery. The QoS level is used when a client sends a subscribe request to a particular topic. When a client subscribes to multiple topics, it can use different QoS level for different topics based on the need.

The amount of data we are going to receive is going to be very large. It is very important we reduce the noise and just give more importance to the signals.

What does each QoS level means ?

QoS 0 — At most once and no guarantee of delivery

QoS 1 — Delivered at least once. It has the possibility of getting the messages multiple times.

QoS 2 — Delivered Exactly once.

Using it in Real time

Take an example of a Fuel level sensor in an manufacturing or an automobile.

The sensors sends data to an indicator which can show the current level of the fuel. The indicator showing the current level just need the live data. It does not need any of the past data and even if it misses to receive a few instances, it does not matter. You can use the QoS 0 (At most Once ) for the Fuel level Indicator.

It can also send data to a cut off valve during filling and fuel low warning when the level recedes the lower optimum level. The fuel cut off or the lower level optimal should not miss the data at any cost. We should use the QoS with the perfect delivery for the warning lights to glow. This mandates the usage of QoS 2 (Exactly Once). Even though the past data is not required in this cases, the exact delivery is a must.

If you build a system that records all the data for future analysis. For example, if we want to study the fuel levels with respect to time, we need all the data to be available for the big data analyser engine. For logging of data and storage, either you should build a engine alongside the broker or you can connect an agent with a QoS 2 (Only Once ) and record all the data remotely.

Don’t Ignore everything as Noise

The determination of whether the data is a Signal or the Noise help decide the QoS level to be used. When we do data publishing and Collection in mission critical industry like healthcare , Nuclear, Defence, etc., every data is important and it mandates the use of QoS 2 for every message. QoS 1 can be used instead of QoS 2, if your client can handle duplicates.

A more detailed document on developing mqtt clients will help you create your own mqtt clients to connect with any mqtt broker.

Leave a comment or write to [email protected] for any questions or suggestions.