Profile PictureLiam Bee
£4.99

Node-Red - Reading / Writing With OPC UA

0 ratings
Add to cart

Node-Red - Reading / Writing With OPC UA

£4.99
0 ratings

What's In This Course?

In this course we'll be covering the following key points:

  • Reading OPC UA Data
  • Writing OPC UA Data
  • Browsing OPC UA Data
  • Subscribing To OPC UA Data
  • Unsubscribing From OPC UA Data

We'll also be covering worked examples and some do's and don'ts around the architecture of OPC UA in Node-Red, identifying the best methods to use to optimize the OPC environment.


What Will You Need To Get Started?

This course is running in the following environment and making use of the following equipment / packages

  • CODESYS 3.5 (SP15 + Patch 1 Onwards)
    • Codesys Soft PLC - See the instructions lecture 3 on how to set this up
  • Node Red (V1.1.3)
    • Running in a Linux Environment on a Virtual Machine (You can use windows, but it's not as stable)
    • Virtual Machine configured as a NAT network connection to the host Windows Machine to access the Soft PLC
    • Individual palette requirements for Node-Red (its simple to download them directly from Node-Red, which is covered a little later)

Please remember that all flows, projects / resources are always available for download from the course's resource section. This will allow you to import the lessons into Node-Red and try things out for yourself

Here's a quick overview of what we are going to run through in this course:

  • READING OPC UA DATA

    • This includes 3 different types of configuration, including setting up the OPC UA Client's Read Environment from a configuration file
  • WRITING OPC UA DATA

    • This lecture also includes multiple examples and configurations of how to write data to an OPC UA Server from Node-Red
  • BROWSING OPC DATA

    • We'll look at how to identify IDs for data in a container on the OPC UA Server. This allows us to quickly gather information on groups and what IDs are present to then go on to read or write. This forms part of a wider system later in the course.
  • SUBSCRIBING / UNSUBSCRIBING TO OPC UA DATA

    • Subscribing to information on the Server is a key part of OPC UA usage and something that forms the basis of the worked examples later in the course. In this lecture, we'll look at Subscribing, Unsubscribing and how to achieve both with a single OPC UA Client node
  • WORKED EXAMPLES

    • The Worked Examples lecture is split in to 5 Examples, each building on the knowledge gained from previous lectures (and introducing some new concepts / node configurations). The end result is pictured above, an example of reading information from the OPC UA Server and storing it globally for access at any point and also in an SQL Database. We'll also be covering methods to ensure data is kept up to date for archives etc.

Setting Up Node Red

If you haven't setup Node-Red yet, you can find all the instructions you need from Node-Red's website:

Linux: https://nodered.org/docs/getting-started/local

Windows: https://nodered.org/docs/getting-started/windows

You'll need to have Node-Red running if you want to practice using the resource material in this course. You don't need to have Node-Red handy for the course, but its recommended to download the resources and try things out for yourself.


Setting Up Codesys

  1. To download CODESYS, you need to access the CODESYS Store and download it for free. You can download it here - https://store.codesys.com/codesys.html - You'll need to sign up to download it, but its all free.
  2. Once you have installed CODESYS 3.5, you will be able to open the project file available in the resource section of this lecture.

  3. Open the downloaded project (Named RPi_OPC - As originally this was set up on a raspberry pi but was adapted for running locally).
  4. Once the project has been opened, head to the windows task tray and start the soft PLC that ships with CODESYS
  5. Double click on the PLC in the CODESYS Project and open the communication settings
  6. Search for a valid PLC in the dropdown menu on the right, the soft PLC should be found automatically

  7. Click the "Login" button 

    Accept the download to the PLC. Once this has completed, a visualisation will open with the control panel used in the project.

Note - The visualization will only run for ~30mins before closing. The PLC will only run for ~2hours before automatically stopping. You will need to restart the soft PLC from the task tray to restart the timers, or alternatively purchase a license from CODESYS to remove the timer restriction

Running a newer version of Codesys? Follow the below steps to remove errors from the project. Codesys changes all the time,  with many different minor versions.

  1. Right click the PLC and choose "Update Device"
  2. Choose the same device (Win V3 x64)
  3. Click Update

This should resolve the issues when building. If it does not, please get in touch!


Installing The OPC UA Node-Red & Other Packages

In order to use OPC UA in Node-Red, you'll need to have access to the above Nodes. These can easily be installed using the Palette Manager that comes with Node-Red.


  1. Click the three line menu button in the top right of Node-Red
  2. Choose Manage Palette
    1. Here you'll be presented with all of the Node packages you have installed.
  3. Click Install
  4. Search for node-red-contrib-opcua
  5. Install by clicking Install


Note: For this tutorial, version 0.2.51 was used

If time has moved on since the making of this course and you need to use version 0.2.51, you can do so by performing the following steps in the Terminal (Linux)

  1. Open Terminal
  2. Use the command cd .node-red
  3. Use the command npm install node-red-contrib-opcua@0.2.51

Make sure you don't miss step 2 else you'll install the node package in the wrong place and Node-Red won't be able to use it.

You'll need to restart Node-Red (Not deploy or refreshing the browser) for changes to take effect.


The following packages are also required - These can be installed via the same method as the above

Add to cart
Copy product URL