In this tutorial, you will learn how to use Node-RED to control a LED connected to the output of a RevPi DIO, connected with a RevPi Connect 4. The tutorial is designed for users familiar with basic programming and IoT concepts who want to integrate hardware and software using industrial-grade components.
The focus will be on:
-
Setting up a Node-RED flow
-
Switching a LED via a web-based Node-RED dashboard
Prerequisites #
Hardware #
✓ RevPi Connect 4
✓ RevPi DIO
✓ 24 V LED
✓ Connection cables for wiring the RevPi DIO and the LED
Software #
✓ Web browser, for accessing the Node-RED interface and PiCtory
Setting up the System #
For detailed instructions, see: Getting Started.
▷ Connect the RevPi Connect 4 to a power source.
▷ Ensure it is connected to your local network for accessibility.
▷ Power on the RevPi DIO.
▷ Check that the 24 V LED is properly connected to the RevPi DIO.
▷ Ensure the RevPi DIO is securely connected to the RevPi Connect 4 via the PiBridge interface.
▷ Open a web browser on a device connected to the same network.
▷ Access the RevPi system using its IP address.

Note
|
For network troubleshooting or determining the IP address of your RevPi, consult the Getting Started guide. |
Step 1: Configuring the Hardware in PiCtory #
▷ Assign appropriate I/O names for easier reference, e.g., Output1_LED.
▷ Save the configuration and restart the driver to apply the changes.
Step 2: Creating a Basic Flow in Node-RED #
▷ Start Node-RED.
▷ Run the following command on a terminal to install the package:
npm install node-red-dashboard
▷ Add a Dashboard switch Node on the Node-RED interface to toggle the LED state.

▷ Open the switch Node node to configure it.

After configuration:

The Revolution Pi palette provides a set of nodes in Node-RED to read and write I/O pins of the Revolution Pi system.

▷ Drag and drop the revpi-output
node to the interface.
▷ Open the nodes to configure them.

After configuration:

For the configuration of the RevPi module nodes, you must enter a server and a pin. After entering the server (in the format <IP address>:8000
), you should automatically be able to select a pin depending on the type of node, whether it is an input or output.
In this case, the Output 1 of the RevPi DIO named Output_LED used.
▷ Drag and drop the debug
node.
The role of this node is to display debugging information and help you troubleshoot by showing messages flowing through the flow.

▷ Select Deploy in the top-right corner of the interface to deploy your Node-RED flow.
❯ This will activate the flow.

Step 3: Quick Test with Prebuilt Flow #
If you prefer to test the flow without manually creating it step by step, you can directly import the JSON export provided below. This flow includes all the necessary nodes to toggle the LED state and visualize the payload in the Debug sidebar.
Prerequisite #
✓ Before importing the JSON, make sure that the Node-RED Dashboard
package is installed.
▷ If not, install it by running the following command in your RevPi terminal:
npm install node-red-dashboard
Importing the Prebuilt Flow #
▷ Copy the JSON export below:
+
[
{
"id": "45371098831c2f50",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "dd91c103fca0df54",
"type": "ui_switch",
"z": "45371098831c2f50",
"name": "ON/OFF",
"label": "switch",
"tooltip": "",
"group": "c5aa454786599927",
"order": 0,
"width": 0,
"height": 0,
"passthru": true,
"decouple": "false",
"topic": "topic",
"topicType": "msg",
"style": "",
"onvalue": "true",
"onvalueType": "bool",
"onicon": "",
"oncolor": "",
"offvalue": "false",
"offvalueType": "bool",
"officon": "",
"offcolor": "",
"animate": false,
"className": "",
"x": 340,
"y": 300,
"wires": [
[
"b97624cf8482ce4c",
"76cf80f93d913ac5"
]
]
},
{
"id": "b97624cf8482ce4c",
"type": "revpi-output",
"z": "45371098831c2f50",
"server": "23bf8ad0f3c174d6",
"outputpin": "O_1",
"overwritevalue": false,
"outputvalue": "",
"x": 620,
"y": 300,
"wires": []
},
{
"id": "76cf80f93d913ac5",
"type": "debug",
"z": "45371098831c2f50",
"name": "debug 1",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 680,
"y": 460,
"wires": []
},
{
"id": "c5aa454786599927",
"type": "ui_group",
"name": "Standard",
"tab": "dfde44665fc52d64",
"order": 1,
"disp": true,
"width": "6",
"collapse": false,
"className": ""
},
{
"id": "23bf8ad0f3c174d6",
"type": "revpi-server",
"host": "<your IP_address>",
"port": "8000",
"user": "pi",
"password": "8e62gy",
"rejectUnauthorized": false,
"ca": ""
},
{
"id": "dfde44665fc52d64",
"type": "ui_tab",
"name": "Home",
"icon": "dashboard",
"disabled": false,
"hidden": false
}
]
▷ Open the Node-RED editor on your RevPi by navigating to:
http://<revpi_ip_address>:1880
▷ In the editor, select the menu (☰) in the top-right corner.
▷ Paste the JSON code into the import window and select Import.
▷ Place the imported nodes on the workspace and select Deploy to activate the flow.
Testing the Flow #
▷ Open the Node-RED Dashboard in your web browser:
http://<revpi_ip_address>:41880/ui
▷ Use the ON/OFF toggle switch in the dashboard to test:
-
Toggling the switch sends a Boolean value (
true
orfalse
) to the Pin: O_1 node, which simulates the LED state.

-
The payload is displayed in the Debug sidebar of the Node-RED editor.
