MQTT Import Service

Content

  • Introduction

  • Register MQTT export service

  • MQTT X setup

  • Publish data to MQTT Import Connector

Introduction

MQTT Import structure to import the data via MQTT protocol. The data flow is shown below.

In this demo we look at publish data using the MQTT X client and Python to MQTT Import Connector; subscribe data with MQTT X client and Postman from MQTT Export. Here are the steps:

  • Register MQTT export service: Create and register MQTT export service.

  • MQTT X setup: Use MQTT 5.0 desktop client on Windows. To follow MQTT export service setup data to configure a new client connection on MQTT X client. After the Topic is successfully subscribed, you can immediately receive EdgeX message in the message box.

  • Publish data to MQTT Import Connector: - MQTT X: After the AnalyticsData Topic of MQTT Import Connector is successfully subscribed, you can publish data from MQTT X. - Python: We provide a Python script to publish data to MQTT Import Connector.

Register MQTT export service

1.Edit “create_mqtt_export_register.bat”

2.Register MQTT export service that execute “create_mqtt_export_register.bat” and “mqtt_export_register.bat”.

MQTT X setup

1.Click below Link and download MQTT 5.0 desktop client on Windows. https://github.com/emqx/MQTTX/releases

2.Click + in the left menu bar or directly click the “+ New Connection” button on the right to configure a new client connection.

3. Client related information. (1) General: a. When configuring the broker information, fill in Name and follow above Table 1 to fill in Host address. Ex.10.0.75.1.

b. Client ID, Host, and Port are already filled in by default. The drop-down box in front of Host is used to select the connection protocol, which supports mqtt: //, ws: //. If an SSL / TLS authentication connection is used, it needs to be modified to mqtts: //. , Wss: //.

c. If your broker has enabled user authentication, you can fill in the information of Username and Password in the configuration item. d. To disable SSL/TLS

d. To disable SSL/TLS

(2) Advanced: In the advanced configuration, you can select the protocol version of MQTT, including MQTT v3.1.1 and MQTT v5.0, and the default is v3.1.1.

(3) Last Will and Testament: Below the advanced configuration, you can configure the Will Message. The values of Last-Will-QoS and Last-Will-Retain are filled with 0 and False by default. When you enter the values of Last-Will-Topic and Last-Will-Payload, you can complete the configuration of Will Message.

(4) Click “Connect”

4.Add subscription (1) Click the New Subscription button in the lower left corner to quickly add a Topic.

(2) Click the New Subscription button in the lower left corner to quickly add a Topic. Follow above Table 1 to fill in Topic: MQTTExport

5. Sending and receiving of messages

(1) After the Topic is successfully subscribed, you can immediately receive EdgeX messages per 20 seconds automatically.

(2) In addition to the above method of automatically to send EdgeX data, the functionality can be tested by posting individual data values using Postman, and then via MQTTX client to check the information from EdgeX.

Publish data to MQTT Import Connector

1.Restart edgex-wrapper to make sure the MQTT Import to receive messages.

2.MQTT X

(1) Through the Payload option in the message bar that add Topic: AnalyticsData and the messages be converted into multiple formats, such as Base64, Hex, JSON and Plaintext.

(2) After the Topic is successfully subscribed, click Send button on bottom right corner.

(3) Publish and subscription on MQTT X.

(4) You can also use Postman to receive the messages. Enter GET request http://10.0.75.1:48080/api/v1/event in Postman.

3.Python script

(1) Edit Python script to publish data with PyCharm.

(2) Receive the data on MQTT X.

(3) You can also use Postman to receive the messages. Enter GET request http://10.0.75.1:48080/api/v1/event in Postman.

Last updated