Using MQTT in xPort Edge and xPico 200

How is MQTT configured in the xPort Edge and xPico 200 modules?

MQTT (Message Queuing Telemetry Transport) is a popular protocol for connecting IoT (Internet of Things) devices and applications using the publish/subscribe model.  This article, explains how to configure MQTT in xPort Edge and xPico 200 families of products and also outlines a simple way to test the feature using the Mosquitto Broker.

xPort Edge MQTT Configuration Diagram

image-20240405-131738.png

To test MQTT functionality in xPort Edge, you would typically need the following:

MQTT Broker: This is the server that receives all messages from the clients and then routes them to the appropriate destination clients. In our case, we are using the Mosquitto Broker.

Topic: Topics are used to filter messages. They are the primary method of routing messages based on the content of the publishing client. When testing MQTT, we need to define and use specific topics for publishing and subscribing.

Client: In this context, the xPort Edge device acts as an MQTT client. It will publish messages to the broker and subscribe to specific topics to receive messages from other clients.

Testing Tool: In our case, we are using MQTT Explorer. This type of tool allows you to connect to the MQTT broker and interact with it, such as publishing messages, subscribing to topics, and monitoring message traffic.

By having these components in place, we can effectively test the functionality of MQTT in xPort Edge, ensuring that it can successfully publish and subscribe to messages via the MQTT broker.

 

Installation of MQTT Broker


The first step is to install the MQTT broker on a PC running Windows. The MQTT broker typically listens on its default port, which is 1883. After installing the Mosquitto Broker, open the Mosquitto.conf file and locate the "listener" configuration. Here, assign the listener port to 1883. Additionally, set the "allow_anonymous" connection to true. Save and exit the configuration file. For example, in a Windows environment where Mosquitto was installed using the Windows installer, the Mosquitto.conf file is typically located in the installation directory, such as C:\Program Files\mosquitto\mosquitto.conf

 

image-20240403-095928.png

 

Configuration in xPort Edge


In the Web Manager for xPort Edge / xPico device, select MQTT. as the protocol in Line 1 configuration, go to the MQTT section in the menu and assign the IP address of the PC where MQTT is installed. Specify the topic name for publishing and ensure that the same topic name is used for subscription. In addition to that, enter the Device ID, which must be unique to the device connected to the server.

 

 

Testing MQTT Functionality

 

To test the functionality of MQTT in xPort Edge, we can use the MQTT Explorer. In the MQTT Explorer, enter the name of the host machine where the MQTT broker is running and listening on port number 1883. Then, click "CONNECT."

Next, send data from the xPort Edge serial port to publish to the MQTT Broker. Any device or application subscribed to the particular topic will receive the data. Additionally, the functionality can be verified using the MQTT Explorer.

By following these steps, we can effectively test MQTT functionality in xPort Edge using the Mosquitto Broker.