Skip to main content

reading a single value

This tutorial will show you how to read a OPC UA Variable when you already know its NodeID or its browse path.

The Read Node is a simple node that allows you to read a single value from a OPC UA server and forward its value to the next node in the flow.

You can specify the nodeId of the variable to read, or its browse path in the configuration of the Read Node itself. Alternatively, you can specify the nodeId in the topic attribute of the Inject Node that triggers the read operation.

Read

Name

You can specify a name for the node, this name will be used in the visual representation of the node in the Node-RED editor.

Endpoint

The Read Node needs to be connected to an OPCUA server endpoint. Choose the endpoint you want to use in the Endpoint field of the Read Node.

see Create a connection to OPC UA server for more details.

NodeId

The nodeId field is optional, you can specify here the nodeId or the browsePath (originated from the /Objects folder) of the variable want to read.

If the NodeId is not specified, you can specify it in the topic attribute of the Inject Node that triggers the read operation.

Note that the injected node topic field takes precedence over the NodeId field of the Read Node. So if you specify a topic in the Inject Node, the NodeId field of the Read Node will be ignored.

NodeId format:

OPC UA for Node-RED supports different ways to specify which node to read.

  • nodeId in BNC format
  • browsePath:
  • verified browsePath.

For instance:

  • direct nodeId
    ns=1;s=Temperature
  • browsePath
    /2:MyDevice/1:MyTemperatureSensor/2:ParameterSet/3:Temperature`
  • verified browsePath:

A verified browsePath is a browsePath that has been verified by the OPC UA for Node-RED node and checked against the OPCUA server address space and that has been converted to a nodeId.

The syntax is the following: [browsePath](nodeId);

for instance:

    [/2:MyDevice/1:MyTemperatureSensor/2:ParameterSet/3:Temperature](ns=1;s=Temperature)`

You can verify your browsePath or your nodeId by clicking on the button representing a 'flask' on the right of the NodeId field.

note

Internal, the Read Node will convert the browsePath to a nodeId, so the nodeId is the preferred way to specify the node to read. This will happens only once, at the first read operation or when a reconnect occurs. So there is only a small performance penalty at the first read operation.

You can also client on the ... button to browse the OPCUA server and pick up the nodeId you are interested in.

:::note: warning!

Note that the browse button will only be effective if you have already configured the endpoint of the Read Node and have also deployed the flow.

:::

reminder !

NodeID can be left empty, if you intend to inject the NodeId in the topic attribute of an Inject node.

reminder !

Be careful, the topic attribute of an Inject node takes precedence if you specify a topic in the Inject Node, the NodeId field of the Read Node will be ignored.

AttributeId

AttributeIdDescription
ValueThe Value attribute is used to read the current value of a Variable.
DataTypeThe DataType attribute is used to read the NodeId of the DataType of the Variable.
BrowseNameThe BrowseName attribute is used to read the BrowseName of the Node.
DisplayNameThe DisplayName attribute is used to read the DisplayName of the Node.
AllAll attributes are read.

:::note:

with the all attribute, the Read Node will return an object containing all the attributes of the node.