# OPC UA and Node-Red

**URL:** <https://discourse.nodered.org/t/opc-ua-and-node-red/3213>\
**Category:** General\
**Created:** [17 September 2018 13:09 UTC](https://discourse.nodered.org/t/opc-ua-and-node-red/3213 "2018-09-17T13:09:19Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Danie](https://avatars.discourse-cdn.com/v4/letter/d/a6a055/32.png) [@Danie](https://discourse.nodered.org/u/Danie)\
**Post date:** [17 September 2018 13:09 UTC](https://discourse.nodered.org/t/opc-ua-and-node-red/3213/1 "2018-09-17T13:09:19Z")

</div>

Hey to all,

i want to use OPC UA in Node-Red to Read from my PLC(Tia V15) and store Data. I don´t now how to process.  
I have try it, but nothing is coming out .

---

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [17 September 2018 14:05 UTC](https://discourse.nodered.org/t/opc-ua-and-node-red/3213/2 "2018-09-17T14:05:06Z")

</div>

In my experience, getting data from OPC is never easy... but you should be seeing some raw data once you get connected. Please give us all the details on which OS, versions of node/npm/nodejs, and the _full module_ name of the node(s) you are trying to use (since there are at least 3 versions in the flows library).

Sharing your flow is probably not helpful right now because we wouldn't be able to test against your specific devices.

---

<div class="post-metadata">

**Author:** ![seth350](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/seth350/32/4617_2.png) [@seth350](https://discourse.nodered.org/u/seth350)\
**Post date:** [19 September 2018 02:44 UTC](https://discourse.nodered.org/t/opc-ua-and-node-red/3213/3 "2018-09-19T02:44:51Z")

</div>

Connecting node-red to OPC-UA is super easy, IF you know what namespace the tag is located in and the actual tag path.

The servers typically sit at:

```
opc.tcp://ipaddress:4840

```

Verify your IP address and port number in your server settings.

The address you enter for your tag should look similar to this example.  
ns=6;s=::AsGlobalPV:PTank.Temperature

To get this information, I suggest finding a free opc-ua client browser. UaExpert is one. This will allow you to at least login to the server and see where tags are located.  
Security settings on the server also need to be verified so that they match in node-red.

---

<div class="post-metadata">

**Author:** ![Danie](https://avatars.discourse-cdn.com/v4/letter/d/a6a055/32.png) [@Danie](https://discourse.nodered.org/u/Danie)\
**Post date:** [19 September 2018 11:17 UTC](https://discourse.nodered.org/t/opc-ua-and-node-red/3213/4 "2018-09-19T11:17:39Z")

</div>

Oh yes. I am using "node-red-contib-opcua" i install it from the Node-red library. all my data are in a DB of my PLC and i am trying to use OPC Ua to Read and Write it.

---

<div class="post-metadata">

**Author:** ![Danie](https://avatars.discourse-cdn.com/v4/letter/d/a6a055/32.png) [@Danie](https://discourse.nodered.org/u/Danie)\
**Post date:** [19 September 2018 11:20 UTC](https://discourse.nodered.org/t/opc-ua-and-node-red/3213/5 "2018-09-19T11:20:45Z")

</div>

Ok thks seth350, i will try it like you suggest and see if it`s works.

---

<div class="post-metadata">

**Author:** ![seth350](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/seth350/32/4617_2.png) [@seth350](https://discourse.nodered.org/u/seth350)\
**Post date:** [19 September 2018 11:49 UTC](https://discourse.nodered.org/t/opc-ua-and-node-red/3213/6 "2018-09-19T11:49:10Z")

</div>

Good luck. I am talking to a B&R plc running node-red.

I will also mention this, once you get it working, each time you place a opcua client node in the flow, it opens another connection to your plc.

You can read and write many tags using just one client node but it will take a little work depending on how many tags you want to read.

Also, since you mentioned Siemens, I believe I have seen a node created to communicate with a Siemens plc. Might also be worth checking out.

---

<div class="post-metadata">

**Author:** ![Danie](https://avatars.discourse-cdn.com/v4/letter/d/a6a055/32.png) [@Danie](https://discourse.nodered.org/u/Danie)\
**Post date:** [19 September 2018 13:00 UTC](https://discourse.nodered.org/t/opc-ua-and-node-red/3213/7 "2018-09-19T13:00:53Z")

</div>

I don´t understand what my Endpoint is? is it My PLC IP-Adresse with the port? or what?  
for the Inject node what is ns and s. Please answer me if you know. because i try several time but nothing is coming out. the opc ua client i use show connecting by the way

---

<div class="post-metadata">

**Author:** ![seth350](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/seth350/32/4617_2.png) [@seth350](https://discourse.nodered.org/u/seth350)\
**Post date:** [20 September 2018 03:36 UTC](https://discourse.nodered.org/t/opc-ua-and-node-red/3213/8 "2018-09-20T03:36:05Z")

</div>

The endpoint is

```
opc.tcp://ipaddress:port

```

This will be the IP address of your plc and the port number the opcua server is running on. Typically, the port is 4840 but you will need to verify your plc configuration.

“ns” = namespace index  
The name space is, from what I understand, a number indicating what “section” of the server the tag is located.  
There are many standard namespaces that will point you to different sections of the server. There is a section for global variables, one for program scope variables, server status, etc.  
You must tell the server which namespace you want to access first.

“s” = string. This is not what you may think. It is not the data type of the tag you want to read, instead it is indicating that you are going to enter a tag address as a string. There are tags in the server that can be read by their nodeID number. To read a tag by nodeID, your address would look like this example:

```
ns=21;i=43

```

Data types can be added to the address and come after the tag location. For example as:

```
...Temperature.Int16

```

I’ll break down my previous example:

```
ns=6;s=::AsGlobalPV:PTank.Temperature

```

I want to read a tag in the server at namespace 6.  
The tag that I want to read is located in folder AsGlobalPV, and the tag is PTank.Temperature.

AsGlobalPV is a folder that contains my global variables on a B&R plc. Siemens may call it something else. TIAGlobal or something.

If you haven’t already, step out of node-red and get a free opcua client application from online somewhere. UaExpert is one off the top of my head. Get connected to your plc using it first. Once you are connected you will see the folder structure I am talking about.

If you can, post some pictures of your opcua server configuration in the Siemens software and also copy your flow from nodered to here.  
I will also look at my configuration when I get back to work.

---

<div class="post-metadata">

**Author:** ![sajidb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sajidb/32/8812_2.png) [@sajidb](https://discourse.nodered.org/u/sajidb)\
**Post date:** [16 April 2019 11:55 UTC](https://discourse.nodered.org/t/opc-ua-and-node-red/3213/9 "2019-04-16T11:55:49Z")

</div>

HI @seth350,  
Do you know how can I browse the data of opcua server using node-red?  
I want to browse all the data and select any data which I want to visualize on dashboard of node-red. Is it possible?  
Thanks

---

<div class="post-metadata">

**Author:** ![seth350](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/seth350/32/4617_2.png) [@seth350](https://discourse.nodered.org/u/seth350)\
**Post date:** [17 April 2019 01:29 UTC](https://discourse.nodered.org/t/opc-ua-and-node-red/3213/10 "2019-04-17T01:29:20Z")

</div>

Yes, it is possible using the OPC Browse node. I have not used it personally.

Basically, you would want the output of the browse node to point to a drop down list on the dashboard. You will more than likely need a switch node in between to filter the output so you only see what you need.

Then, let the output if the drop down list go to an OPC Read node.

Your mileage may vary.

---

<div class="post-metadata">

**Author:** ![sajidb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sajidb/32/8812_2.png) [@sajidb](https://discourse.nodered.org/u/sajidb)\
**Post date:** [17 April 2019 11:26 UTC](https://discourse.nodered.org/t/opc-ua-and-node-red/3213/11 "2019-04-17T11:26:40Z")

</div>

I have tried using the Browser node and the template node together. But I am struggling with it which I posted here but got no response yet.

> [@How to use OPCUA Browser and Template nodes together \[SOLVED\]](https://discourse.nodered.org/t/how-to-use-opcua-browser-and-template-nodes-together/9937):
>
> I want to connect to OPCUA server and get the data on the dashboard. For the solution, I am using OPCUA Browser node and the template node. [image] But I don't know how to browse the data. I am using the following code for template: \<div layout="row" layout-align="space-between"\> \<select ng-model="item" ng-options="items.item.displayName.text for items in msg.payload"\> \<option value=""\>-- Objects Root --\</option\> \</select\> \<button ng-click="send({payload: {actiontype: 'browse', root: it…

Maybe you can help me with that. Thanks.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [17 April 2019 11:51 UTC](https://discourse.nodered.org/t/opc-ua-and-node-red/3213/12 "2019-04-17T11:51:52Z")

</div>

With the `node-red-contrib-iiot-opcua` nodes, there are a ton of built in samples.

Node-red Editor --\> menu (top RH corner) --\> import --\> examples --\> iiot opcua

Have you looked here for clues?

---

<div class="post-metadata">

**Author:** ![sajidb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sajidb/32/8812_2.png) [@sajidb](https://discourse.nodered.org/u/sajidb)\
**Post date:** [17 April 2019 14:27 UTC](https://discourse.nodered.org/t/opc-ua-and-node-red/3213/13 "2019-04-17T14:27:53Z")

</div>

Hi @Steve-Mcl,  
I have looked into the examples, In examples either I have to inject or filter the data to get the desired data so I need to know what I am browsing for and what should I get.  
On the contrary, I require a solution in which the available data should be there and when I select a particular node, then the data should be displayed accordingly. For this, I wanted to use template node from the dashboard package but I don't know how to develop a solution like this.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [17 April 2019 17:23 UTC](https://discourse.nodered.org/t/opc-ua-and-node-red/3213/14 "2019-04-17T17:23:17Z")

</div>

What I've done in the past is use uaexpert like @seth350 said...

> [@seth350](#):
>
> If you haven’t already, step out of node-red and get a free opcua client application from online somewhere. UaExpert is one off the top of my head

With that, I browse the OPCUA server, find the tags of interest, copy the path and paste it into node-red.

I'm certain once you can so it statically you can do it dynamically (IE entering a tag name into dashboard field).

---

<div class="post-metadata">

**Author:** ![sajidb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sajidb/32/8812_2.png) [@sajidb](https://discourse.nodered.org/u/sajidb)\
**Post date:** [18 April 2019 08:24 UTC](https://discourse.nodered.org/t/opc-ua-and-node-red/3213/15 "2019-04-18T08:24:45Z")

</div>

@Steve-Mcl, Thanks for your kind response. I have done it statically. I want to do it dynamically. For that purpose, I think I need to use a template node and get all the data from root node and then select a particular node to show the data. But I don't know how to get that.

---

<div class="post-metadata">

**Author:** ![Digs\_10](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/digs_10/32/8774_2.png) [@Digs\_10](https://discourse.nodered.org/u/Digs_10)\
**Post date:** [27 May 2019 12:15 UTC](https://discourse.nodered.org/t/opc-ua-and-node-red/3213/16 "2019-05-27T12:15:22Z")

</div>

@seth350 i have a similar case but the problem is that i am not able to get any output in the debugging tab.  
I have an injecter connected to a OPC UA client who is further connected to read, response and debug in order respectively.  
The session is active in OPC UA client.

---

<div class="post-metadata">

**Author:** ![sajidb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sajidb/32/8812_2.png) [@sajidb](https://discourse.nodered.org/u/sajidb)\
**Post date:** [27 May 2019 12:33 UTC](https://discourse.nodered.org/t/opc-ua-and-node-red/3213/17 "2019-05-27T12:33:16Z")

</div>

@Digs_10,  
Can you share the screenshot of your flow?

---

<div class="post-metadata">

**Author:** ![Digs\_10](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/digs_10/32/8774_2.png) [@Digs\_10](https://discourse.nodered.org/u/Digs_10)\
**Post date:** [27 May 2019 12:39 UTC](https://discourse.nodered.org/t/opc-ua-and-node-red/3213/18 "2019-05-27T12:39:38Z")

</div>

![hell](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/3/3d8e0636bef626ca4dc7919c46210d7bdc097fff.jpeg)  
here is the flow sir

---

<div class="post-metadata">

**Author:** ![sajidb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sajidb/32/8812_2.png) [@sajidb](https://discourse.nodered.org/u/sajidb)\
**Post date:** [27 May 2019 12:56 UTC](https://discourse.nodered.org/t/opc-ua-and-node-red/3213/19 "2019-05-27T12:56:42Z")

</div>

The first thing I notice is that you're using 2 modules.  
node-red-contrib-opcua and node-red-contrib-iiot-opcua.

OPC UA Client needs the nodeid at input if it is in READ or SUBSCRIBE mode. What is timeRead injecting?

You don't need to use READ and Response to read something from the server. There may be multiple ways to do it. The easiest way which I know is to use Inject node where you define the nodeid and the OPC UA Client node wher you define the endpoint and the action (READ in this case) and put a debug node at the output of the OPC UA Client node. You will get something.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/5/54b518026e799a81253b7d85f6def6d909691024.png)

---

<div class="post-metadata">

**Author:** ![Digs\_10](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/digs_10/32/8774_2.png) [@Digs\_10](https://discourse.nodered.org/u/Digs_10)\
**Post date:** [28 May 2019 04:17 UTC](https://discourse.nodered.org/t/opc-ua-and-node-red/3213/20 "2019-05-28T04:17:34Z")

</div>

Wow  
This is amazing sir!  
Thanks a lot!  
I just have one doubt: what is the difference between 'node-red-contrib-opcua' and 'node-red-contrib-iiot-opcua'? I've googled the question but didn't get any clear-cut answer. It would be just great if you could explain in brief sir!

Also i tried what you said but...here is the output

 ![27](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/96e18b1f823ef621cc5b32ee2635d20f84a2d74c.jpeg)

[Next page](https://discourse.nodered.org/t/opc-ua-and-node-red/3213.md?page=2)
