MQTT

The Internet of Things or IOT is all about interconnecting devices and one lightweight, secure way for online devices to communicate is using MQTT.
MQTT is a Publish/Subscribe based messaging protocol that avoids direct connections between devices by relaying data through a central server called the broker.

1.Client
A program or device that uses MQTT. A Client always establishes the Network Connection to the Server. It can:

  1. Publish Application Messages that other Clients might be interested in.
  2. Subscribe to request Application Messages that it is interested in receiving.
  3. Unsubscribe to remove a request for Application Messages.
  4. Disconnect from the Server.

2.Server:
A program or device that acts as an intermediary between Clients which publish Application Messages and Clients which have made Subscriptions. A Server:

  1. Accepts Network Connections from Clients.
  2. Accepts Application Messages published by Clients.
  3. Processes Subscribe and Unsubscribe requests from Clients.
  4. Forwards Application Messages that match Client Subscriptions.

3.Subscription:
A Subscription comprises a Topic Filter and a maximum QoS. A Subscription is associated with a single Session. A Session can contain more than one Subscription. Each Subscription within a session has a different Topic Filter.

4.Topic Name:
The label attached to an Application Message which is matched against the Subscriptions known to the Server. The Server sends a copy of the Application Message to each Client that has a matching Subscription.
The central concept in MQTT to dispatch messages are topics. A topic is a simple string that can have more hierarchy levels, which are separated by a slash. A sample topic for sending temperature data of the living room could be house/living-room/temperature. On one hand the client can subscribe to the exact topic or on the other hand use a wildcard. The subscription to house/+/temperature would result in all message send to the previously mention topic house/living-room/temperature as well as any topic with an arbitrary value in the place of living room, for example house/kitchen/temperature. The + sign is a single level wild card and only allows arbitrary values for one hierarchy. If you need to subscribe to more than one level, for example to the entire subtree, there is also a multilevel wildcard (#). It allows to subscribe to all underlying hierarchy levels. For example house/# is subscribing to all topics beginning with house.

5.Topic Filter:
An expression contained in a Subscription, to indicate an interest in one or more topics. A Topic Filter can include wildcard characters.

6.Session:
A stateful interaction between a Client and a Server. Some Sessions last only as long as the Network Connection, others can span multiple consecutive Network Connections between a Client and a Server.

For more information on MQTT please click Protocol MQTT: How to get started

Configuring MQTT Server

For this MQTT demonstration we are using a Free Public Entreprise MQTT Broker called HiveMQ accessible using the following Link

In order to configure an MQTT Server retrieve the MQTT connection settings information as shown bellow and follow the steps accessible at How to Add an MQTT Application

Host: broker.hivemq.com
TCP Port: 1883

Please note that the CemTore MQTT Application should end up looking like the bellow screenshot.

Visualise Data on an MQTT Explorer

In order to visualise your Data please follow the steps below.

1/ Download an MQTT Explorer.
For this demonstration we are using a free MQTT Explorer Application available for Windows, Mac, Linus & Ubuntu.

Download the MQTT Explorer

2/ Open the MQTT Explorer application and enter the following parameters.

3/ Click on the ADVANCED button.

4/ Subscribe to the Topic wanted and click the ADD button.

5/ In order to make sure the Topic was added check the Subscription List.
Then Click the BACK Button

6/ Press the Connect button.

7/ Visualise your Data payload that will appear under the MQTT Broker on the top left of the Application.

Feedback

Was this helpful?

Yes No
You indicated this topic was not helpful to you ...
Could you please leave a comment telling us why? Thank you!
Thanks for your feedback.

Post your comment on this topic.

Post Comment