How To Articles > How to Access OPC UA Data Via MQTT

How to Access OPC UA Data Via MQTT

How to Access OPCUA Data Via MQTT


Open Automation Software Tags can be defined to connect to OPC UA Servers with the built in OPC UA Driver Interface. This tutorial walks you though downloading and installing OAS, configuring an OPC UA driver, configuring tags and logging them to a database. This tutorial walks you though downloading and installing OAS, configuring an OPC UA driver, configuring tags and reading and writing to them via MQTT.

Step 1. Download and Install the Open Automation Software and Start the OAS Service

If you have not already done so, you will need to download and install the OAS platform.  Fully functional trial versions of the software are available for Windows, Windows IoT Core, Linux, Raspberry Pi and Docker on our downloads page.

On Windows run the downloaded Setup.exe file to install one or more of the Open Automation Software features. Select the default Typical installation if you are not sure what features to use or the Custom installation if you want to save disk space on the target system.  When prompted agree to the End User License Agreement to continue the installation.

For more detailed instructions and video tutorials, visit the installation guide for your system:
Windows Installation | Linux Installation | Raspberry Pi Installation | Dockers Installation

The OAS Service Control application will appear when the installation finishes on Windows.  Use this application to start the 3 Services. Run the Configure OAS application on Windows and select Configure-Tags; if the first time running, the AdminCreate utility will run to create an Administrator login as shown in Step 1 of Getting Started – Security.


Step 2. Configure Your OPC UA Data Source

  1. First, you will need to open the Configure OAS application from the program group Open Automation Software.

  2. Select Configure >> License from the top menu and verify that OPC UA is one of the available Drivers in the lower left of the form. The demo license will have this by default. If you do not see OPC UA available, contact support@openautomationsoftware.com to update your license.

  3. Select Configure >> Drivers from the top menu.


  4. Select localhost or the remote service you wish to modify with the Select button to the right of the Network Node list.


  5. The Configure Drivers Screen will appear. Select Siemens from the Driver dropdown box.


  6. Enter a meaningful Driver Interface Name that you will refer to this physical connection when defining Tags with a OPC UA Data Source.

  7. Define the properties for the desired physical connection.

  8. Click the Add Driver button above the Driver list in the left pane to add the Driver Interface as an available selection when defining Tags in the next step.

For more detailed instructions on configuring your OPC DA data source, click here to see our Getting Started OPC UA tutorial.


Step 3. Configure Your Tags

OAS provides multiple ways to add and define tags:

To add a Tag manually:

  1. In the OAS Configure Application, select Configure >> Tags from the top menu.


  2. Select localhost or the remote service you wish to modify with the Select button to the right of the Network Node list.


  3. Click on the Add Tag button located at the top of the Tag browser on the left portion of the screen.


  4. A dialog box will appear. Enter a name for your new tag and click ok.

  5. A configuration screen will appear for your new tag. Select your data source type in in the Data Source dropdown box.


  6. Specify the correct data type in the Data Type dropdown box.

  7. Click Apply Changes at the bottom right of the window.

For more detailed instructions on configuring your tags, click here to see our Getting Started Tags tutorial.


Step 4. Access Your Data with the OAS MQTT Broker

The OAS MQTT broker will work without configuration but if you want to use SSL or have security set on your OAS Service you will need to configure it. Please see our Getting Started – MQTT Broker page in the knowledge base if this applies to you.

Accessing Your Tag Data (Subscribing)

This example uses MQTT Explorer, it is a free MQTT client and you can download it here.



Enter the address of your MQTT Broker in the host name. This will be the IP address or domain name of where you have the OAS Server installed. If it is on your local machine, you can just enter localhost. The name field is just a friendly-name so enter something meaningful to you, perhaps your Broker ID. Enter the Port and Username and Password if you have set one up. Click on the Advanced button.




Here is where you can subscribe to your topics (OAS tags). In the Topic box, enter TagName.Value, for example, Ramp.Value and click Add. You can also subscribe to any other property of the tag, for example, Ramp.DataSource. Once you are done adding topics, click Back.




Now click on save and then connect. You should now see your data coming in. The payload is in standard JSON format and includes the Value, Timestamp, and Quality.

Writing to Your Data Source (Publishing)

Follow the same setup for the MQTT Explorer client that you did for subscribing to connect to the OAS MQTT Broker but you can skip the Advanced button part. Click Connect.




In the lower right portion of the client window, enter in your Topic, this will be the tag you are trying to write to, for example, MyValueTag.Value. Switch the selector to raw and enter a value in the text box below the Publish button. Click Publish. If you would like to write your value in json format, you can. Using the JSON Calculations in OAS you can parse the JSON message for extended functionality.

The video below, goes into detail about how to do that as well as an overview of the OAS Broker.