MQTT <-> OPC UA Client Bridge

1,380 views
Skip to first unread message

Artyom Syomushkin

unread,
Apr 9, 2016, 5:48:24 AM4/9/16
to Node-RED
Hi there,

I'm quite a beginner with Node Red. I want to organize a bidirectional MQTT to OPC UA Bridge. E.g. from MQTT side it should connect to some broker and from other side it should act like OPC UA Client, e.g connect to some OPC UA Server.
The bridge should forward data from one protocol to another. In case of MQTT origin it should subscribe to all topics and when new message is published it should take topic name, resolve, based on it, UPC UA variable name and write topic payload as a value to OPC UA server.
And in case of OPC UA origin, it should subscribe to all browsable variables on OPC UA Server and publish messages with variable name as topic and value as payload to MQTT Broker when OPC UA variable is updated.

Sounds easy, but I'm beginner and need some help. I found Node-Red to be useful in this case, because as it's description suggests, it's designed to wire IoT, and also because I found that it supports required protocols. E.g. MQTT is out of the box and OPC UA client is available as http://flows.nodered.org/node/node-red-contrib-opcua

I started with OPC UA to MQTT direction and got first problem. I want to use Raspberry PI as HW platform for this bridge. So I installed all things and created first workflow on it... and OPC UA is not working. E.g. it says, that session active, but no browsable information is displayed. At the same moment I installed Node-Red and on windows PC - and that one is working correctly. So first problem is that node-red-contrib-opcua nodes seem to be not work on Raspberry Pi. Is there any Idea how to debug this?

 
 

 

Mark Setrem

unread,
Apr 9, 2016, 6:10:09 AM4/9/16
to Node-RED
What version of node-red, node.js and npm have you got installed. (The first two are listed when you start up nodered)
You can find out which version of npm you have installed using
The command npm -v

Julian Knight

unread,
Apr 9, 2016, 9:46:25 AM4/9/16
to Node-RED
You might also want to paste a copy of your example flow here as well which will help people understand what you are doing. Select the relevant nodes then use the hamburger menu and export them. Copy to the clipboard and paste into a message.

Artyom Syomushkin

unread,
Apr 9, 2016, 3:33:53 PM4/9/16
to Node-RED
Yes, sure. This is simplest flow, which browses for variables on OPC UA Server.
[{"id":"8cb54d53.0c123","type":"inject","z":"c7d1793f.b2582","name":"Read DeviceSet on PI Model","topic":"ns=2;i=5001","payload":"","payloadType":"str","repeat":"","crontab":"","once":true,"x":173.1999969482422,"y":249,"wires":[["33d42f.f03943d2"]]},{"id":"33d42f.f03943d2","type":"OpcUaClient","z":"c7d1793f.b2582","endpoint":"opc.tcp://192.168.0.40:4840","action":"browse","time":"","name":"Browse CODESYS PI OPC UA Server","x":537.4000244140625,"y":246,"wires":[["cd8f433b.f167c8"]]},{"id":"cd8f433b.f167c8","type":"debug","z":"c7d1793f.b2582","name":"Browsed JSON","active":true,"console":"false","complete":"true","x":865.4000091552734,"y":250.99998474121094,"wires":[]}]

On Windows PC it works fine - it returns many messages in debug window. But when I copy paste it to RPI and deploy it runs only once showing correct debug data, but when I depoy it next time it doesn't print anything.
Here are the versions:
9 Apr 11:43:23 - [info] Node-RED version: v0.13.4
9 Apr 11:43:23 - [info] Node.js  version: v0.10.29

pi@raspberrypi:~ $ npm -v
2.15.2

 

Mark Setrem

unread,
Apr 9, 2016, 4:00:32 PM4/9/16
to Node-RED
and what about on the Windows machine where it works?

My guess is that on the windows machine you have a newer version of nodejs and it would be worth following the instructions on
http://nodered.org/docs/hardware/raspberrypi under "Manual Install" to install a newer version of nodejs to see if that fixes the issue.

If it doesn't I would suggest you open an issue on the github page for the node https://github.com/mikakaraila/node-red-contrib-opcua/issues

Dave C-J

unread,
Apr 9, 2016, 6:25:29 PM4/9/16
to node...@googlegroups.com

Hi Artyom,
I recall having to a) make sure I was using npm v2.x and b)  preinstall the underlying node-opcua package (before then adding the node-red-contrib.. package) for some reason.  The pi I used is in the office so I can check on Monday

Artyom Syomushkin

unread,
Apr 10, 2016, 3:48:20 AM4/10/16
to Node-RED
Hi Dave,

I haven't installed onde-opcua package on both Raspberry or Windows PC. It's also not said in node-red-contrib-opcua that this package should be installed first.
On WindowsPC i have newer version of node.js:
10 Apr 09:43:41 - [info] Node-RED version: v0.13.4
10 Apr 09:43:41 - [info] Node.js  version: v4.4.2

Julian Knight

unread,
Apr 10, 2016, 4:17:06 AM4/10/16
to Node-RED
I think that might be an artifact of the gradual changes to npm. I've noticed that problem myself with a couple of nodes.

Dave C-J

unread,
Apr 10, 2016, 4:48:40 AM4/10/16
to Node-RED
Hi 

On Pi I was using the default Node.js v0.10.32 but have to upgrade npm to v2.x 
    sudo npm i -g npm@2.x

then
   cd ~/.node-red
   npm i node-opcua node-red-contrib-opcua

Yes I was using a previous version of node-red-contrib-opcua so it may have changed - but it was definitely working against the Schneider IGSS demo suite.

Artyom Syomushkin

unread,
Apr 10, 2016, 4:53:15 PM4/10/16
to Node-RED
Strange,

after I updated Node.js to v4.4.2 on my Raspberry and used npm i node-opcua node-red-contrib-opcua I broke something:
now I lost OPCUA-Client Node - during start Node-red issues warning: [OpcUa-Client] Error: Cannot find module 'collections/set' and doesn't load the node.
Also the view of OPC UA nodes was changed. Before it was like this:


And now it looks like this:

What happened?
 

Auto Generated Inline Image 1
Auto Generated Inline Image 2
Reply all
Reply to author
Forward
0 new messages