Mastering Forge #10: Configuring OPC UA Pub Sub Communication

Welcome to the 10th tutorial on our series Mastering Forge.

In our previous article, Mastering Forge #9, we used the Event Generator to create new events in Forge, enabling event-based communication.

In this article, we will configure Pub Sub communication. We’ll start by publishing variables and events using the OPC UA Publisher module, and then we’ll demonstrate how to receive Pub Sub messages using the OPC UA Subscriber module.

If you prefer tutorials in video format, you can watch our video tutorial on configuring OPC UA publishers and subscribers with Forge on our YouTube channel.

During this tutorial, we’ll be using the following products:

    •  

Configure OPC UA Publisher

To follow this tutorial, create an object in Forge’s address space with a variable mapped to Prosys OPC UA Simulation Server’s Sinusoid variable.

OPC UA Publisher – Connections-related terminology to help you follow this tutorial:

  • Writer Group: Defines common headers and settings for all included Data Set Writers.
    • Data Set Writer: Writes the data in the selected Data Set to the Pub Sub message with additional headers defined in the Data Set Writer configuration.
      • Data Set: Two types are supported.
        • Variable Data Set: Cyclic messages of Variable nodes.
        • Event Data Set: Acyclic messages with event property data.

1. From the Dashboard, start the OPC UA Publisher Module.

Forge's dashboard view, starting OPC UA Publisher Module

2. Start Forge’s internal MQTT broker. Click the menu icon () on the top right corner and select MQTT Broker.

A screenshot of Forge's advanced menu opened and a pink arrow is pointing to MQTT Broker settings.

3. Enable the configuration to start the internal broker. To change the status, click the toggle at the top right corner of MQTT Broker settings.

A screenshot of Forge's internal MQTT Broker settings. A pink arrow is pointing to Enable toggle.

Configure Variable Data Set

1. Navigate to OPC UA Publisher > Variable Data Sets and click + Add DataSet.

A screenshot of Variable Data Set view. Pink arrows are pointing to OPC UA Publisher on main navigation bar and to Variable Data Set on sub navigation bar. Third arrow points to button Add DataSet.

2. Here, you will create a group for the variables you want to publish in the same message. Start by giving the DataSet a name. Optionally, select a root node for the variables added to this DataSet by selecting a node for Browse Root.

A screenshot of filled variable DataSet configuration.

3. Finally, add the variables you want to include in the DataSet. Click the list icon and then the plus icon to search for a node.

A screenshot of configured variable dataset and a pink arrow is pointing to list icon button and another to plus icon button.

Configure Event Data Set

1. Next, we are going to configure a new Event DataSet. Navigate to OPC UA Publisher > Event Data Sets and click + Add DataSet.

2. Enter a name for the DataSet.

3. For Event Node, choose the object node containing the events you want to publish.

4. Add the event fields you want to include in the message. By clicking the plus icon, you will get a dialog where you can browse and select the fields.

A screenshot of event dataset configuration form. A pink arrow is pointing to plus icon button next to Selected Event Fields.

5. Select the fields from this dialog and click Save.

A screenshot of Select Event Fields dialog. List of available event fields and SourceNode, Time, and Message are selected.

6. Finally, click Add to save the event dataset configuration.

A screenshot of filled event data set configuration.

Configure Connection

1. Navigate to OPC UA Publisher > Connections and click + Add Connection.

A screenshot of OPC UA Publisher's Connections view. A pink arrow is pointinng to button Add Connection.

2. Provide a name for the connection.

3. Under Connection address settings, select mqtt:// from the dropdown. The connection details will default to the internal broker. Click Add.

A screenshot of filled OPC UA Publisher connection form.

Configure Writer Group

1. Navigate to OPC UA Publisher > Writer Groups and click + Add Writer Group.

2. Name the Writer Group and set the Publishing Interval to 1000 ms. Click Save.

A screenshot of filled writer group configuration.

3. Click the list icon, then click the plus icon to add a new Data Set Writer.

A screenshot of Writer Group view. Pink arrows are pointing to list icon button and plus icon button.

4. Select the created Data Set from the dropdown list.

A screenshot of New Data Set Writer dialog. Data Set dropdown list is opened and MyCoffeeVariables is selected.

5. Click Add with the default configuration values.

6. Follow the same steps to add the event Data Set Writer.

A screenshot of New Data Set Writer dialog. Configuraitons are filled with MyCoffeeEvents parameters.

Subscribe with Prosys OPC UA Browser

1. Open Prosys OPC UA Browser.

2. Write the connection address mqtt://localhost:1883 to Browser’s address bar and start connecting.

3. Set MQTT Topic Filter to # and click OK.

A screenshot of MQTT settings dialog in Prosys OPC UA Browser. # is set to MQTT Topic Filter.

4. Check the PubSub tab for parsed messages and the Log tab for raw messages in Browser.

A screenshot of Prosys OPC UA Browser Pub Sub view.

Configure OPC UA Subscriber

1. Start the default OPC UA publisher from Simulation Server. You must use Expert Mode (Options > Switch to Expert Mode) to access the PubSub tab.

A screenshot of Prosys OPC UA Simulation Server PubSub tab. PubSub is set to Running state with default settings.

2. From the Dashboard, start the OPC UA Subscriber Module.

Forge's dashboard view, starting OPC UA Subscriber Module.

3. Go to Data Sources > OPC UA Subscriber and click + Add Subscriber.

A screenshot of Forge's OPC UA Subscribers view. Pink arrows are pointing the navigation route, Data Sources from the main navigation bar and then OPC UA Subscriber from the sub navigation bar. One pink arrow points to button Add Subscriber.

4. Update the settings for the subscriber.

  1. Provide a name for the subscriber.
  2. Select mqtt:// from the Protocol dropdown list.
  3. Set localhost to the Hostname field.
  4. Use port number 1883.
  5. Click Save.
A screenshot of filled OPC UA Subscriber configurations.

5. Navigate to OPC UA Server > Address Space.

6. Browse Data Sources > OPC UA Subscribers to see the variables received from the broker. Your subscriber is successfully configured if you can find the variables.

A screenshot of Forge's Address Space. Data Sources, OPC UA SUbscribers are expanded to show the data received with the OPC UA Subscriber.

Next Steps

This wraps up the 10th article of the Mastering Forge series. Here’s a recap of what we did in this tutorial:

  1. Started Forge’s internal MQTT broker.
  2. Configured an OPC UA publisher (that will publish over MQTT).
  3. Configured an OPC UA subscriber and used it to Receive data over MQTT.

In our next article, Mastering Forge #11, we’ll use Forge’s Exchange module, which is used to actively exchange data between servers.

If you want to learn more about Forge and its capabilities, you can request a detailed introduction by emailing sales@prosysopc.com or using our contact form. We’d be delighted to provide tailored information about Forge that aligns with your interests and requirements.

A headshot of Iivo Yrjölä

Iivo Yrjölä

Customer Integration & Support, Prosys OPC

Email: iivo.yrjola@prosysopc.com

Related Posts

Interested in this topic?

Get updated about new posts through our newsletter!
Scroll to Top