Reading From The Server

Setting Up The Inject Node

First, we need an Inject Node, which is a basic node that is part of Node-RED and can be found under the common tab.

Most of the Inject node’s properties can be left at their default values. Optionally it can be named and the two fields that are generated by default can be removed. What needs to be set-up is the Repeat field., which should be configured to interval from the dropdown list and set to 0.1 seconds#fig:inject-node[2.1].

Inject node configuration

Setting Up The Item Node

The second step is to create Item nodes for the variables we want to query. Since we want to track the status and readings from the sensors, we will need four Item nodes: two nodes for the temperature sensor and two nodes for the light sensor.

The temperature sensor is in namespace 2 and the light sensor is in namespace 3. The first Item node will be for the current temperature#fig:currenttemp-node[2.2].

  • Item field: The CurrentTemp variable is in namespace 2 and has an index of 6011, so we set it to ns=2;i=6011.

  • Type field: CurrentTemp is of type Double.

  • Value field: This field does not need to be set up since it is only used when creating a Node-RED OPC-UA server.

  • Name field: The name can be set to anything, it will be set to CurrentTemp for clarity and future ease of use in other nodes.

CurrentTemp Item node properties

This is repeated for the other three values we want to track.

Afterwards, we connect all four Item nodes to the Inject node#fig:inject-item[2.3].

Connect Item nodes to the Inject Node

Setting Up The Client Node

The third step is to connect the Item nodes to the Server node. Since all four Item nodes will be used to track the values of the four variables, we only need a single Client node#fig:client-node-properties[2.4].

  • Endpoint field: We set it to one of the IP:PORT URLs on which the server listens.

  • Action field: We decide to go with SUBSCRIBE, we could as well go with READ.

  • Interval field: We set it to 10 milliseconds.

  • Other fields are optional.

Client node properties

NOTE: In place of the IP, you can and should use a DNS name. In the Sandbox environment use base-opc-ua-server.

Now we connect the four Item nodes to the Client node. All four are connected to the same client node, so we save up the number of connections to the server#fig:item-client[2.5].

Connect Item nodes to the Client node