View on GitHub

UA-IIoT-StarterKit

Samples and tutorials to illustrate how to build OPC UA PubSub applications.

OPC UA IIoT StarterKit – Setup Ubuntu Environment

Overview

  1. Install and Configure MQTT Broker
  2. Install and Configure .NET Core
  3. Build StarterKit Code

Install and Configure MQTT Broker

These steps explain how to set up an insecure broker for testing. A broker used in production applications would need to have TLS enabled and some sort of client authentication.

Install Mosquitto Broker with these commands:

sudo apt update
sudo apt install mosquitto

Download Java 8 from here. For Ubuntu 64-bit the download is the “Linux x64 Compressed Archive”.

cd ~/
tar -xvf jre-8u291-linux-x64.tar.gz 

Download mqtt-spy from here.

mkdir ~/mqtt-spy
cd ~/mqtt-spy
~/jre1.8.0_291/bin/java -jar mqtt-spy-1.0.0.jar 

To connect to a broker using mqtt-spy:

Install and Configure .NET Core

Install Visual Studio Code:

sudo apt install code

Manually download Visual Studio Code from https://code.visualstudio.com/ if necessary.

Install the following extensions (select extensions icon on right side toolbar):

Install .NET Core SDK:

sudo snap install dotnet-sdk --classic

Test installation:

mkdir helloworld
cd helloworld/
dotnet new console
dotnet build
dotnet bin/Debug/net6.0/helloworld.dll 

If all is good the following output should be printed:

Hello World!

Build StarterKit Code

Fetch code from GitHub:

cd ~/
git clone --recursive https://github.com/OPCFoundation/UA-IIoT-StarterKit.git

Build code:

dotnet build .\UA-IIoT-StarterKit.sln

Run code

cd ~/UA-IIoT-StarterKit/build/bin/Debug/UaMqttPublisher/net6.0
dotnet UaMqttPublisher.dll --help

The following output should be produced:

An application that produces OPC UA PubSub messages sends them to an MQTT broker.

Usage: UaMqttPublisher [command] [options]

Options:
  -?|-h|--help  Show help information.

Commands:
  publish       Produces OPC UA PubSub messages sends them to an MQTT broker.

Run 'UaMqttPublisher [command] -?|-h|--help' for more information about a command.

Running the MQTT Publisher
Running the MQTT Subscriber