Your browser does not support JavaScript!

Oleksandr Zdir


MQTT - the language that the Cloud can speak

5 Minutes

Send to your friends


1. What is MQTT?
2. Major characteristics of MQTT
3. MQTT and Niagara Framework®

1. What is MQTT?


MQ Telemetry Transport (MQTT) is a very simple client/server, publisher/subscriber, open and lightweight messaging transfer protocol. What is unique about this protocol, is that it is perfectly suited for IoT needs, because it has been designed for small devices with minimal resource requirements. Thus MQTT can often be seen in Smart Home automation systems alongside cloud services such as AWS, Google Cloud IoT Core, Microsoft Azure IoT, IBM IoT Platform and other cloud market leaders. Another important distinction is that this communication standard allows devices to publish messages that are not previously known or predetermined. ‘Whatever you say, I'm listening’ is true as long as the client subscribed to the related topic. The middleman is a broker which receives and stores the messages so they would be available for interested clients. That gives an advantage in case of not stable communication. There is no need for two clients to be ‘on-line’ at the same time to share information. As long as the message was received by the broker, it would wait for the interested subscriber whenever he would get a connection. Similar principles of work can be seen on Instagram, you don't need to be available 24/7, the posts from the profiles to which you are subscribed are waiting for you on the server.

MQTT Broker is responsible for receiving all the messages, filtering them, registering who is interested in them and redirecting the messages to interested clients. Additionally, as a boss of the protocol, it authenticates and authorizes clients.


Picture 1. Communication Schema in MQTT


Interesting Fact: You are probably using MQTT on a daily basis without even knowing it, that's because Facebook uses MQTT communication for Messenger Chats and on Instagram.

Basically, all Building Management Systems companies support MQTT in their BMS Software. Among them are Tridium's Niagara Framework® (version 4.2 or higher), Johnson Controls Metasys®, Schneider Electric’s EcoStructure™ and Lynxsprings Onyxx®.  MQTT is one of those rare protocols which ‘cloud can speak’ and EDGE devices can process. Because of that MQTT is often called one of the best-known protocols for the Internet Of Things in the Building Automation Industry.  


2. Major characteristics of MQTT.


To better understand MQTT, it is essential to know the basic building blocks on which this protocol is built.

There are certain messages that MQTT devices use to communicate with the broker and vice versa. The main are the following:

  • Connect (Client to Server) - creates a connection with a broker. 
  • Connack   (Server to Client) - an acknowledgment of the connection.
  • Disconnect (Client to Server or Server to Client)- disconnects with a broker.
  • Publish (Client to Server) - publishes topic’s data to the broker.
  • Subscribe (Client to Server) - subscription request.
  • Unsubscribe (Client to Server) - unsubscription request.

MQTT is a secure protocol. The messages between the client and broker can use SSL/TLS encryption to ensure communication security over a network.

Message Structure in MQTT is designed to have a small footprint. The messages are consist of:

  • Fixed Header, which consists of the message type, DUP Flag, QoS (Quality of Service) and Retain.
  • Variable Header Component
  • Message Payload


Picture 2. Structure of an  MQTT Message


What's interesting is that QoS allows choosing the likelihood of message delivery between client and broker. There are three specified levels:

  • QoS0: Message will be delivered at most once, meaning there is a likelihood of some messages being lost.
  • QoS1: Message will be delivered at least once, meaning that duplication of messages may sometimes occur.
  • QoS2: Message will be delivered exactly once, meaning no duplication and no message loss. You may be wondering why there is such classification? Wouldn’t it be enough to use QoS2 all the time and avoid losses and redundant messages? The trick is that the lower the QoS level, the higher the performance. So there is a possibility to choose what is more important for each particular case, performance or quality of communication.

3. MQTT and Niagara Framework®


The implementation of MQTT is available in Niagara Framework® through the driver “Abstract MQTT Driver”. The driver contains three components:

  • AbstractMqttNetwork.
  • AbstractMqttDevice.
  • AbstractMqttPoints.

It is possible to add multiple devices to the different brokers (Broker IP Address and Port must be specified) under one network. In each device, it is possible to choose one of three levels of Quality Of Service described previously.

The points under driver are standard type: Boolean, Numeric, String and Enum but with two variations: Publish (if you want to send data to the broker) and Subscribe (if you want to read data from the broker). Each point should contain a specified MQTT Topic.  

Important to know that Niagara Framework® has a JSON toolkit that allows it to gather the data available on the station of the controller and allows it to publish that data via MQTT, oBIX, HTTP etc. in a fast and standardized way.

Other articles by this author

Smart Buildings / HVAC&R / IoT

Sensors in Building Automation

read the article
Good Engineering Practices (GEP)

Importance of Automation Control Panel

read the article

Can BMS save the World?

read the article