An infographic explaining how Node-RED's visual, flow-based programming allows users to build edge control logic without writing code.

Using Node-RED for Simple Edge Control Logic and Prototyping

Written by: Robert Liao

|

Published on

|

Time to read 5 min

Author: Robert Liao, Technical Support Engineer

Robert Liao is an IoT Technical Support Engineer at Robustel with hands-on experience in industrial networking and edge connectivity. Certified as a Networking Engineer, he specializes in helping customers deploy, configure, and troubleshoot IIoT solutions in real-world environments. In addition to delivering expert training and support, Robert provides tailored solutions based on customer needs—ensuring reliable, scalable, and efficient system performance across a wide range of industrial applications.

Summary

This guide demonstrates how to use Node-RED for simple edge control logic and rapid prototyping on an industrial gateway. We'll explain how this powerful, low-code visual programming tool empowers OT engineers—not just professional developers—to build their own "sense-decide-act" loops. By following a simple tutorial, you'll learn how to create a real-world edge control application using a drag-and-drop interface, dramatically accelerating the journey from idea to working prototype.

Key Takeaways

Node-RED is a visual, flow-based programming tool that allows you to build applications by wiring together pre-built nodes, like digital LEGO® bricks.

It is the perfect tool for OT professionals to build simple edge control logic and prototypes without writing a single line of traditional code.

This tutorial will show you how to build a complete "sense-decide-act" loop: reading a physical input on an EG5120 and using it to trigger a physical output.

Running Node-RED on a reliable, open platform like the EG5120 provides the industrial-grade hardware foundation needed to move your prototype from the lab to the factory floor.

I've had this conversation with so many brilliant OT engineers. They know their machinery and processes inside and out. They have a clear goal: "I just want to read the status of this safety gate, and if it opens, I need to turn on a warning light immediately." The problem? They're not a Python programmer. The thought of writing, compiling, and deploying code is a major barrier.

What if you could draw that logic instead of writing it? What if you could build that entire application in five minutes using a drag-and-drop interface?

Let's be clear: you can. The tool that makes this possible is called Node-RED, and it's the ultimate "superpower" for enabling OT experts to implement their own edge control ideas.


An infographic explaining how Node-RED's visual, flow-based programming allows users to build edge control logic without writing code.


What is Node-RED? "Drawing" Your Control Logic

At its heart, Node-RED is a free, open-source, flow-based programming tool that runs in your web browser. Instead of writing lines of code, you build your application visually:

  • Nodes: Each node is a pre-built block with a specific job (e.g., "read a digital input," "check a value," "send an email").
  • Flows: You connect the output of one node to the input of another with "wires" to create a "flow"—your complete application.

The real 'aha!' moment is when you realize it's a visual way of thinking that is incredibly intuitive for anyone who understands process logic.

Building a Simple Edge Control Loop with Node-RED

Let's build a real edge control application: if a machine's safety gate opens (detected by a sensor on a Digital Input), we will turn on a red warning light (connected to a Digital Output). We'll build this on an EG5120.

Step 1: Set Up the "Sense" Node

First, we need to read the state of the safety gate sensor, which is wired to Digital Input 0 (DI0) on the EG5120.

  1. Drag an  Exec node onto the workspace. This node can run any underlying Linux command.
  2. Configure it to run the command cat /sys/class/gpio/gpio460/value to read the state of DI0.
  3. Set it to repeat this command periodically, for example, every 1 second.

Step 2: Set Up the "Decide" Node

Now, we need to check the value we just read.

  1. Drag a  Switch node onto the workspace and connect it to the output of the Exec node.
  2. Configure the Switch node to check the message payload. Create two rules:
    • If the payload == "1" (the gate is open), send the message to output 1.
    • If the payload == "0" (the gate is closed), send the message to output 2.

Step 3: Set Up the "Act" Nodes

Finally, we need to control the warning light connected to Digital Output 0 (DO0).

  1. Drag two  Exec nodes onto the workspace.
  2. Configure the first one to run the command echo 1 > /sys/class/gpio/gpio464/value (Turn DO0 ON). Connect this to the first output of your Switch node.
  3. Configure the second one to run echo 0 > /sys/class/gpio/gpio464/value (Turn DO0 OFF). Connect this to the second output of your Switch node.

Click "Deploy." Your low-code edge control application is now live. When the safety gate opens, the warning light will instantly turn on. When it closes, the light will turn off.


A screenshot of the Node-RED flow built in the tutorial, showing how to read a digital input and control a digital output for a simple edge control loop.


Conclusion: Empowering the True Experts

Edge control is not just for professional software developers. With intuitive, low-code tools like Node-RED running on an open and reliable hardware platform like the Robustel EG5120, the power to automate and innovate is placed directly into the hands of the people who know the industrial process best: the OT engineers and technicians on the factory floor. This is how you bridge the skills gap and dramatically accelerate your journey toward a smarter, more responsive operation.

Further Reading:

A solution diagram showing the physical wiring of a switch and a light to the EG5120's DI/DO, which is being controlled by a Node-RED flow.


Frequently Asked Questions (FAQ)

Q1: Is Node-RED powerful enough for a real industrial control task?

A1: For many simple-to-medium complexity tasks, absolutely. Node-RED is excellent for data routing, protocol conversion, creating alerts, and executing conditional logic like in our tutorial. For high-speed, safety-critical, or computationally massive tasks, a "pro-code" application written in Python or C++ might be more appropriate.

Q2: How is this different from programming a PLC?

A2: PLC programming (like ladder logic) is a specialized skill and is designed for highly deterministic, microsecond-level machine execution. Node-RED is a higher-level tool that is much more flexible and easier to learn. It excels at integrating different systems (e.g., reading a PLC with Modbus, calling a weather API, and sending an email), which would be very difficult to do in a PLC.

Q3: Can my Node-RED flow talk to a PLC?

A3: Yes. This is one of its most powerful features. By installing the Modbus or S7 nodes, your Node-RED flow running on the EG5120 can directly read and write data to your PLCs, allowing you to use Node-RED as a simple, visual SCADA or control logic supervisor for your existing automation.