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 ClientSettings:
    • 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 Device → Nodes
  2. Go to Devices → Nodes
  3. Create subscription node:
      1. Name: IoT_Sensors
      Channel
    1. Open PrimaryStation and configure: MQTTClient
      1. Subscribe Topic: sensors/+/temperature
      2. QoS: 1

      The '+' wildcard subscribes to all sensors.

      Create Points for Subscribed Data
        1. BrokerURL: 127.0.0.1
        2. Port: 502
        3. ClientID: FrameworX

      Create Points

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

      Temperature Tank 1 Sensor:

      • Name: Sensor1_TagName: TankFarm/Tank1/Temp
      • Node: IoT_Sensors
      • Topic: sensorsTankFarm/sensor1Tank1/temperature
      • Data Type: Double
      • JSON Path: $.value (if JSON payload)
      • AccessType: Read

      Temperature Tank 2 Humidity Sensor:

      • Name: Sensor1_Humidity TankFarm/Tank2/Temp
      • Node: IoT_Sensors
      • Topic: sensorsTankFarm/sensor1Tank2/humiditytemperature
      • Data Type: Double

      Publish Tag Values

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

      Temperature Tank 3 Sensor (write):

      • Name: TankFarm/Tank3/Temp
      • Node: IoT_Sensors
      • Topic: TankFarm/Tank3/temperature
      • Data Type: Double
      • AccessType: Write



      Test Connection

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

      Next Steps

    8. CONNECT (Reference) - Explore list of connectors
    9. [Enrich Data & Scripts] - Process MQTT data
    10. [Secure & Deploy] - Production security

In this section...

Page Tree
root@parent
spaces93DRAF