MQTT (Message Queuing Telemetry Transport) is a lightweight messaging protocol designed specifically for IoT (Internet of Things) environments. It operates on a publish-subscribe model, allowing devices to publish messages to topics and other devices to subscribe to those topics to receive the messages. MQTT is well-suited for scenarios with limited bandwidth and intermittent connectivity, making it an efficient solution for IoT deployments. Its lightweight nature minimizes protocol overhead, optimizing data transmission and conserving network resources. With MQTT, you can establish reliable and scalable communication between devices and servers, enabling seamless integration and data exchange within your IoT ecosystem.
To establish a connection with an MQTT broker, the following parameters must be accurately entered:
Parameter |
Description |
Data Type |
Host |
The name or IP address of the MQTT broker |
String |
Port |
The port number on which the MQTT broker listens |
Int |
Username (Optional) |
Username to connect to the MQTT broker |
String |
Password (Optional) |
Password to connect to the MQTT broker |
String |
Client ID (Optional) |
Client ID for the connection |
String |
ConnectionTimeoutSeconds |
Timeout in seconds for connection attempt |
Int |
KeepAliveSeconds |
Keep alive time in seconds |
Int |
FlattenModeledValues |
Whether to flatten modeled values |
Bool |
Parameter |
Description |
Data Type |
Topic |
Topic to subscribe to |
String |
To view the results of the MQTT subscription or
publication, the user can use a client library or an MQTT client tool to
monitor the subscribed topic or published messages. The client library or tool
will typically display the incoming or outgoing messages in a result window or
log. By defining the MQTT topic and selecting the appropriate QoS level, users
can effectively subscribe to an MQTT broker. Once the input has been defined,
the user can execute the query and view the results to ensure that the data has
been successfully transferred to the target table.
If multiple topics are to be subscribed to using topics that can be distinguished by index, the index button can be activated. After the index button is opened, words are added from the Word list that appears on the screen. The starting point for the relevant index is written in Min Index. The endpoint is added in Max Index and finally, the increment value is selected for how much the increase will be between min and max. After all these selections, the relevant index numbers can be individually selected from the bottom list or all of them can be selected using the select all button. After these steps, when "create input" is clicked, multiple inputs will be created at the same time.
To publish data with MQTT, it is necessary to define an output. This can be done by selecting the appropriate output connector in the MQTT integration platform and configuring the required parameters. To create an output, specify the required details such as the output name, output topic, and QoS.
Parameter |
Description |
Data Type |
Topic |
Topic to publish to |
String |
QoS |
Quality of service (0, 1, or 2) |
Int |
The EMQX interface operates by default on port
18083. By accessing this address, one can establish a connection to the MQTT
broker within Maestro. Once the connection is established, it is possible to
subscribe to specific topics and view the data that is published or publish
data to those topics. By subscribing to the "demo_mqtt" topic that
has been created, the relevant data published to that topic will be displayed
on the screen. This screen provides a means to perform pub-sub verification through
EMQX, as data flow continues to appear on the screen whenever a new topic is
published.