OPC UA IIoT StarterKit – Setup Ubuntu Environment
Overview
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:
- Create a connection to the broker;
- Subscribe to all topic (enter ‘#’ as the topic name);
- Publish to a text topic and verify the response was received.
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):
- C#
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.