Skip to content

AzureIoTGBB/OPC-UA-Publisher-on-IoT-Edge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 

Repository files navigation

# Under Construction




How to Install and Configure the OPC-UA Publisher on IoT Edge


Assumptions


  1. An IoT Hub has been setup and configured in an Azure subscription that you have access to. If you need to understand how to configure an IoT Hub see this article.
  2. An Azure IoT Edge device has been configured on a device that is running Linux.
  • If you need to understand how to install IoT Edge on x64 see this article.
  • If you need help on how to install IoT Edge on Linux ARM32 see this article.

Install the OPC-UA Publisher


Once the Edge is running on a device (or VM) we need to ensure that it is healthy. To do this run the following command

sudo systemctl status iotedge

You should see an output like you see below:

image

The part to pay attention to is the bit in green "active (running)" This tells us that IoT Edge is installed and connected to an IoT Hub in Azure.

Next we need to create a file for the OPC Publisher configuration.

From the shell prompt in the terminal session type the following:

sudo mkdir /shared

Now we need to create our file in this directory. To do this we will type:

sudo nano /shared/pn.json

If nano is not your favorite editor...feel free to use what you like.

paste the following in the file.

[
  {
    "EndpointUrl": "opc.tcp://1xx.1xx.1xx.1xx:Port",
    "UseSecurity": false,
    "OpcNodes": [
      {
        "Id": "ns=2;s=Channel1.Device1.Tag1",
        "OpcSamplingInterval": 2000,
        "OpcPublishingInterval": 5000
      }
    ]
  }
]

Enter your OPC-UA Server's IP address and port number for the "EndpointURL".

Save this file.

Deconstructing the pn.json file


EndpointUrl entry must contain the opc.tcp:// followed by the server's OPC server's IP address : and the OPC server's Port number.

UseSecurity

OpcNodes This is where you enter your Name Space and tags that you are wanting to sample and publish

  • ID This is where we will insert the OPC namespace and tags. The easiest way to find the tag and name space is to use a tool like UA Expert. For our discussions we will be using this tool. Once the tool is installed, open the tool. Once the tool starts up you will be asked to create a certificate. Enter the required data. Once UA Expert gets to the application view perform the following steps:

  • image

  • Then click OK

  • Now you should see your OPC Server listed under the "Servers" folder:

  • Project Window
  • Right click on the OPC Server and select connect:

  • ServerConnect
  • Now UA Expert should connect to your OPC Server. Once it does you can see the following "tree view" at the bottom pane:

  • Tag Tree
  • Use the tree view to navigate to the tags that you are looking for and then drag them to the center pane.

  • Tree Drag
  • In the following picture shows the "ID" section information. The NS shows the name space number "NS=2". The "String" is the "s" after the ";". and then everything in the third box makes up the rest of the string.

  • String Lay Out

The next step is to install the module for OPC-UA Publisher. To do this you will need to log into the Azure Portal. Once you are on the Azure portal navigate to the resource group that holds your IoT Hub and select the IoT Hub.

image

On the IoT Hub blade select the IoT Edge on the left hand side.

image

On the IoT Edge blade find the IoT Edge device that we will be adding the OPC-UA Publisher to.

image

Select "Set Modules" at the top

image

Click on the Add as seen below:

image

Click on "Edge Module".

image

This will open a new fly out as scene below.

image

Here we will be filling in the following:

  1. Name
  • iot-edge-opc-publisher
  1. Image URI
  • microsoft/iot-edge-opc-publisher:latest
  1. Container Create Options
  • Enter the following replacing the port binding port to the one that you are using in your OPC server deployment. Replace the with the OPC Server name and IP address as such: “KeithOPCserver1.useast.cloudapp.azure.com:10x.2xx.6x.1”
{
    "Hostname": "publisher",
    "Cmd": [
      "publisher",
      "--pf",
      "/cfg/pn.json",
      "--aa"
    ],
    "HostConfig": {
      "PortBindings": {
        "62222/tcp": [
          {
            "HostPort": "62222"
          }
        ]
      },
      "Binds": [
        "test_cfx509certstores:/root/.dotnet/corefx/cryptography/x509stores",
        "/shared:/cfg"
      ],
      "ExtraHosts": [
      "<OPC Server Host Name and IP>"
      ]
    }
  }

and click image.

At the bottom of the blade you will see the drawing, click next.

In the next section you will need to modify the route. Enter the following:

{
  "routes": {
    "upstream": "FROM /* INTO $upstream"
  }
}

Click Next.jpg

Click Submit

Check to see if the data is flowing in to the IoT hub. To do this we will type the following command at the shell prompt on the

Finally, for more information you can view this article, and this article

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published