You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 12 Next »

Manage MQTT SpB connections to read and write data.

Scripts → Tutorial | Concept | How-to Guide | 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 Device channels
  • Set up TagProvider Services

1. Setup MQTT Environment

Start Built-in MQTT Broker

  1. Go to DataExplorer → MQTT Tools
  2. Click Start button for Local Built-in Broker (check the message on the right side or the icons to make sure it's not already running)
  3. Status shows "TMQTTBroker is Running"

Start MQTT Simulator

  1. In same panel, find MQTT Publisher Simulator section
  2. Click Start for simulator
  3. Status show "Simulator is Running

2. Configure SpB Publisher with Devices

Create Device Channel

  1. Go to Devices → Channels
  2. Click New Channel
  3. Configure:
    • Protocol: Mqtt SparkplugB Publisher
    • Channel Name: SpbPublisher
    • Group ID: SpbPublisherGroup
  4. Click OK

Create Device Node

  1. Go to Devices → Nodes
  2. Click New Item
  3. Configure:
    • Node Name: SpB_Publisher_Node
    • Channel: SpbPublisher
    • Node ID: SpbNode
  4. Click OK
  5. On Primary Station, once its using the local broker, just by pressing Test  it should show the OK message


MQTT Spb Tag Structure

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.

Create Tag User Type

  1. Go to Unified Namespace → User Types
  2. Click on Insert new
    1. New Name: MotorSpb
    2. Create new UserType
  3. In the MotorSpb UserType add:
NameType
TemperatureDouble
PressureDouble
RPMInteger

Create Tag using UserType

  1. Go to Unified Namespace → Tags
  2. Add the tag Motor1 and set type to use MotorSpb UserType

Map Tags to Publisher

  1. Go to Devices → Points
  2. Add:
    1. TagName: Motor1
    2. Node: SpB_Publisher_Node
    3. Address: Motor1SpB

3. Test Publisher

Start Runtime

  1. Press F5 to start test mode
  2. Open Property Watch
  3. Navigate to Tag.Motor1
  4. Change Values

Verify Publishing

  1. Return to DataExplorer → MQTT Tools
  2. Click Refresh on connected browser
  3. Navigate to topic:
    LocalBroker/spBv1.0/SpbPublisherGroup/SpbNode/Motor1SpB
    
  4. See published metrics:
    • Pressure
    • RPM
    • Temperature
  5. Change values in the property watch to see them reflecting here

4. Configure SpB Collector with TagProvider

Create TagProvider Services Connection

  1. Go to Unified Namespace TagProvider Services 
  2. Click New Item...
  3. Configure:
    • Name: MqttSpB_Collector
    • Provider: MQTT SparkplugB Collector
    • Access Mode: Read
    • Click Test (the OK message should show up)
  4. Click OK

5. Map Collected Data to Tags 

Create Asset Folder

  1. Go to Unified Namespace → AssetTree
  2. Create folder MqttSpb
  3. Click on Insert Data from TagProvider
  4. Navigate the tree TagProvider Services → MQTTspB and select this folder
  5. Now you can navigate into the tree and the entire structure will be available to use



In this section...

The root page @parent could not be found in space 93Draft.



  • No labels