MQTTspB exercices and configuration

Tutorials → Tutorial | MQTT | How-to Guide | MQTT Tools Reference

This Tutorial Teaches you to:

  • Start the MQTT internal broker
  • Start the MQTT SpB Simulator
  • Set up publishers using Device channels
  • Set up collectors using  TagProvider Services

Prerequisites



Step 1: Set Up the MQTT Broker and Simulator

Start the Built-in Broker

  1. Navigate to Data Explorer → MQTT Tools
  2. Click Run Local Built-in Broker to start the broker
  3. Connect to the broker (connection will show as established)

Run the MQTT Publisher Simulator

  1. Start the MQTT Publisher Simulator
  2. Verify data is publishing - you'll see:
    • Cities (e.g., Barcelona)
    • Solar panels with properties:
      • Name
      • Power
      • Temperature
      • Real-time changing values

Step 2: Map and Publish Data Using Devices

Create Device Mapping

  1. Select a panel (e.g., Panel 1) from the simulator
  2. Click Map to the Solution
  3. Choose Publisher and New DeviceNode
  4. Confirm to create tags automatically

Configure Channel Settings

  1. Go to Devices → Channels
  2. Confirm if all the setting are as expected, including the Group ID from the broker.

Configure Node Settings

  1. Go to Devices → Nodes
  2. Confirm if all the setting are as expected, including the Node ID from the broker.

Configure Points

  1. Check Points section for mapped tags (e.g., PAN01)
  2. Verify the address structure:
    • Group ID: cities
    • Node ID: Barcelona
    • Device ID: Panel_1


MQTT Spb Tag Structure

If you are creating tags manually, instead of mapping directly from the Data Explorer, It is important to note that when using MQTT SpB, all the tag must be in a structure. It means that you need to create a user type and use the root level of the user type in the communication.

Step 3: Collect Data Using Tag Provider

Create Tag Provider

  1. Navigate to Frameworks → Tag Provider Services
  2. Click Create New Tag Provider
  3. Select MQTT SparkPlug B Collector Connector
  4. Change the setting to connect to your broker
  5. Test the broker connection

Link to Asset Tree

  1. In Asset Tree, create a folder (e.g., "Barcelona")
  2. Link the tag provider to this folder
  3. Navigate the tree structure to see values

Access Asset Data

  1. Open Tools → Object Browser
  2. Navigate to your asset (e.g., Barcelona → Panel1 → Current)
  3. Copy the asset path using the top button
  4. Paste this path anywhere in the software to retrieve values

Step 4: Configure Runtime Publishing

Enable Local Tag Publishing

  1. In Runtime → Startup, before running the solution, check "Publish to MQTT Broker" option (Advanced settings)
  2. This automatically publishes public local tags to the broker

Create Local Tags (Optional)

  1. Go to Unified Namespace > Tags
  2. Create a new local tag (e.g., "LocalTagPower")
  3. Set visibility column to Public for read/write access
    • Public: Read and write access
    • Protected: Read-only access
    • Private: Tag not visible

Step 5: Run and Monitor the Solution

Start Runtime

  1. In Runtime → Startup, Click Run Startup
  2. Verify all connections are active

Monitor Data Flow

  1. Use Diagnostic Tools → Property Watch to monitor tag values
  2. Use Object Browser to:
    • Navigate to specific tags (e.g., Barcelona → Panel1 → Current)
    • Copy tag paths
    • Add tags to watch lists for testing

Verify Data Collection

  1. Check that asset values are updating in real-time
  2. Confirm data is flowing from:
    • Simulator → Broker
    • Broker → Device mappings
    • Tag Provider → Asset tree

In this section...