Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Connect to a MQTT broker (Tutorial) teaches how to:

  • Configure MQTT client
  • Subscribe to topics
  • Publish tag values using Sparkplug B
  • Map topics to tags

Prerequisites:

To Do:

  • Split this example on Collector and Publisher
  • Use MQTT Explorer

In this page:

Table of Contents
maxLevel2
minLevel2
indent10px
excludeSteps
stylenone

    
Devices →  Tutorial | Concept | How-to Guide | Reference


Configure MQTT Client

  1. Navigate to Devices → Protocols
  2. Select MQTT Client
  3. Create channel:
    • Name: MQTTClient
    • Protocol: MQTT Client
    • Settings:
      • Broker URL: test.mosquitto.org (or your broker)
      • Port: 1883 (or 8883 for SSL)
      • Client ID: FrameworX_001
      • Keep Alive: 60 seconds

Set Authentication (if required)

For secured brokers:

  • Username: Your username
  • Password: Your password
  • SSL/TLS: Enable if using port 8883
  • Certificates: Browse to certificate files

Subscribe to Topics

  1. Go to Devices → Nodes
  2. Create subscription node:
    • Name: IoT_Sensors
    • Channel: MQTTClient
    • Subscribe Topic: sensors/+/temperature
    • QoS: 1

The '+' wildcard subscribes to all sensors.


Create Points for Subscribed Data

  1. Navigate to Devices → Points
  2. Add points for each expected topic:

Temperature Sensor:

  • Name: Sensor1_Temp
  • Node: IoT_Sensors
  • Topic: sensors/sensor1/temperature
  • Data Type: Double
  • JSON Path: $.value (if JSON payload)

Humidity Sensor:

  • Name: Sensor1_Humidity
  • Node: IoT_Sensors
  • Topic: sensors/sensor1/humidity
  • Data Type: Double

Publish Tag Values

  1. Create publish Device Channel and Node:
    • Protocol: MQTT Publisher 
    • Name: SCADA_Publisher
    • Publish Mode: On Change
  2. Configure published points:
    • Tag: Select tag to publish
    • Topic: scada/line1/production
    • QoS: 1
    • Retain: True (optional)

Test Connection

  1. Start Runtime
  2. Open Devices → Monitor
  3. Use MQTT client tool (like MQTT Explorer) to:
    • Publish test messages
    • Verify FrameworX publishes

Best Practices

  • Use meaningful topic hierarchies
  • Set appropriate QoS levels
  • Enable retain for configuration data
  • Implement Last Will and Testament
  • Use SSL/TLS in production
  • Next Steps

      [AWS IoT Core Connector] - Cloud integration
    • CONNECT (Reference) - Explore list of connectors
    • [Enrich Data & Scripts] - Process MQTT data
    • [Secure & Deploy] - Production security

    In this section...

    Page Tree
    root@parent
    spaces93DRAF