How-To Guides
Integration Guides

Generic MQTT Integration Guide (HiveMQ)

8min

Review the following guide for setting up an integration between Manufacturing Connect Edge and an MQTT broker using HiveMQ.

HiveMQ's MQTT broker is designed for cloud native deployments to make optimal use of cloud resources. The use of MQTT reduces network bandwidth required for moving data.

Before You Begin

You must download MQTT Explorer.

Visit the MQTT Dashboard to find the settings required in the MQTT Explorer application.

Step 1: Connect MQTT Explorer

To connect MQTT Explorer:

  1. Open MQTT Explorer.
  2. Click the Add icon to create a new connection.
  3. In the Name field, enter a name for the connection.
  4. In the Host field, enter broker.hivemq.com.
  5. In the Port field, verify that 1883 is entered.
  6. Click CONNECT.

Step 2: Add Generic MQTT Connector

Follow the steps to Add a Connector and select the MQTT - Generic provider.

Configure the following parameters.

  • Name: A recognizable name to identify the connector.
  • Hostname: Enter broker.hivemq.com.
  • Port: Confirm that the default value 1883 is entered.
  • Client ID: Enter 1.
  • Username: Leave this field blank.
  • Password: Leave this field blank.
  • QoS: Select 0.
  • Parallel Publish Count: Enter 100. The number of messages being published simultaneously. Once the defined limit has been reached, subsequent messages are silently dropped.
  • Integration Topic: Enter mqtt_topic.
  • LWT topic: The topic for MQTT's Last Will and Testament feature. You can leave this value blank.
  • LWT payload: The payload for MQTT's Last Will and Testament feature. You can leave this value blank.
  • LWT payload type: The payload type for MQTT's Last Will and Testament feature. The options are string and base64.
  • LWT QoS: The Quality of Service value for MQTT's Last Will and Testament feature. The default value is 1.
  • LWT retained: Select this check box to retain the value for MQTT's Last Will and Testament feature.
  • Throttling limit: The maximum number of messages per second to be processed. The default value is zero, which means that there is no limit.
  • Persistent storage: When enabled, this will cause messages to undergo a store-and-forward procedure. Messages will be stored within Manufacturing Connect Edge when cloud providers are online.
  • Queue Mode: Select the queue mode as lifo (last in first out) or fifo (first in first out). Selecting lifo means that the last data entry is processed first, and selecting fifo means the first data entry is processed first.

Step 3: Enable the Connector

After adding the connector, click the toggle in the connector tile to enable it.

Document image


If you see a Failed status, you can review the Connector Logs and relevant error messages.

Step 4: Create Topics for Connector

To add the outbound and inbound topics to the MQTT Connector:

  1. Navigate to Integration.
  2. Click the MQTT - Generic connector tile.
  3. Click the Topics tab.
  4. Click the Add a new subscription icon. The Data Integration dialog box appears.

    Add a new subscription icon
    Add a new subscription icon
    
  5. Configure the following parameters.
    • Data Direction: Select Local to Remote - Outbound.
    • Local Data Topic: Enter a local data topic name.
    • Remote Data Topic: Confirm the topic where the data is pushed. This is the Integration Topic value for the connector.
    • Enable: Select the toggle to enable the topic.
  6. Click OK to add the topic.
  7. Click the Add a new subscription icon again to add the inbound topic.
  8. Configure the following parameters.
    • Data Direction: Select Remote to Local - Inbound.
    • Local Data Topic: Enter a local data topic name. For example: local_topic.
    • Remote Data Topic: Confirm the topic where the data is pushed. This is the Integration Topic value for the connector.
    • Enable: Select the toggle to enable the topic.
  9. Click OK to add the topic.

Step 5: Verify Connection in MQTT Explorer

You can verify the connection in MQTT Explorer by subscribing to the topics for the connector.

Step 5a: Add Topic to MQTT Explorer

You will need to add the topic name you configured for the connector in MQTT Explorer.

To add the topic to MQTT Explorer:

  1. Open MQTT Explorer.
  2. Click DISCONNECT.
  3. Select the connection you created earlier.
  4. Click ADVANCED.
  5. In the Topic field, enter the Integration Topic value you configured in Step 2. In this use case, the value is mqtt_topic.
  6. Verify the QoS value is 0.
  7. Click +ADD.
  8. Click BACK.
  9. Click SAVE, and then CONNECT.

Step 5b: Test Connection in Flows Manager

You can test the connection by sending a message through the Flows Manager.

To test the connection in Flows Manager:

  1. In Manufacturing Connect Edge, navigate to Flows Manager.
  2. Click the Go To Flow Definition icon for a selected Flows Manager. The Flow canvas opens in a new browser tab.

    Go To Flow Definition icon
    Go To Flow Definition icon
    
  3. From the flow canvas, drag the DataHub Publish node (DataConnector section) and Inject node (Common section) to the canvas.

    The DataHub Publish and Inject nodes
    The DataHub Publish and Inject nodes
    
  4. Connect the two nodes.

    The Inject node and DataHub Publish node connected
    The Inject node and DataHub Publish node connected
    
  5. Double-click the DataHub Publish node. The Edit DataHub Publish Node dialog box appears.
  6. In the Topic field, enter the topic name you configured for the outbound topic you created for the connector.
  7. If needed, configure the Datahub Publish connection. See Configure Connector Nodes to learn more.
  8. Click Done.
  9. Double-click the Inject node. The Edit Inject Node dialog box appears.
  10. In the msg.payload field, select string and enter test MQTT connection.
  11. In the msg.topic field, enter the topic name you configured for the outbound topic you created for the connector.

    Inject node properties
    Inject node properties
    
  12. Click Done, and then Deploy.
  13. Click the Inject node button to send the "test MQTT connection" message to the topic.

    Document image
    
  14. Verify that the message displays in MQTT Explorer.

    Message sent from the Flows Manager to the MQTT topic
    Message sent from the Flows Manager to the MQTT topic