OPC-UA is a platform-independent service-oriented architecture for IIoT. This article uses the installation you created in the AWS-Greengrass tutorial to deploy OPC-UA as an AWS Lambda function on an ARTIK Linux module.
OPC-UA via AWS Greengrass
This procedure demonstrates how to connect to the OPC-UA server, monitor the required nodes, and publish the necessary details to both AWS and ARTIK Cloud. For doing so, an AWS-Greengrass Lambda function is used to manage the OPC-UA client running on the AWS-Greengrass core device (ARTIK 530/710). The Lambda function transmits the monitored OPC-UA node value required to ARTIK Cloud.
You must have an account on Samsung ARTIK Cloud; you may have already set it up during the Connect to the World article.
Follow the AWS Services articles to get an AWS account and set up AWS Greengrass.
Perform these one-time setup operations.
Create New Device Type
You need to set up a device with named parameters as noted.
Create a new Device Type in ARTIK Cloud – Developer Portal. Include the following fields in the manifest file, and then publish the device type.
Using the Device Type you just created, create a new instance of the device in your ARTIK Cloud User Portal. Leave the window open so that you can copy the Device ID and token later.
Install OPC-UA Server
Clone the node-opcua repo.
git clone git://github.com/node-opcua/node-opcua.git
git checkout v0.0.64
Install the npm dependency packages.
Run the OPC-UA server. You'll use this command every time you need to restart the server.
Implement Lambda function
Implement a AWS Lambda function that uses nodejs runtime.
Download the file bundle that contains the Lambda function, which is also the OPC-UA client.
After creating the AWS Greengrass group, upload the lambda zip file by following the steps described in the AWS Lambda package creation article.
NOTE: The runtime should be Node.js 6.10.
Publish a version of the uploaded Lambda function and add it to the Greengrass group. Update the configuration as described in the AWS Greengrass configuration article.
NOTE: Update the Memory Limit to 100 MB.
Include the following Environment variables, copying and pasting the Device ID and Token from above (and getting your IP address from
“opcuaserver” – “opc.tcp://<HOST_IP_ADDRESS>:26543”
“artikDeviceId” – “_your_DEVICE_ID_goes_here_”
“artikDeviceToken” – “_your_DEVICE_TOKEN_goes_here_”
Run the OPC_UA server (if not running already).
Start Greengrass service on the core device and deploy.
Setting up greengrass daemon Validating hardlink/softlink protection Validating execution environment Found cgroup subsystem: cpuset Found cgroup subsystem: cpu Found cgroup subsystem: cpuacct Found cgroup subsystem: blkio Found cgroup subsystem: memory Found cgroup subsystem: devices Found cgroup subsystem: freezer Found cgroup subsystem: net_cls Found cgroup subsystem: perf_event Found cgroup subsystem: net_prio Found cgroup subsystem: pids Found cgroup subsystem: debug Starting greengrass daemon Greengrass successfully started with PID: 2574
Now, you should be able to see the data in Artik cloud corresponding to the data value of the monitored node, obtained from the OPC-UA server. Appropriate actions can be triggered using the ARTIK Cloud Rules engine.
To view the data logs in AWS dashboard, subscribe to the uploaded Lambda to IoT cloud service as described here.
NOTE: Subscribe to topic “#” to view the data logs.