Document toolboxDocument toolbox

Node-RED Tutorial

In this tutorial, we will guide you through setting up the Node-RED desktop environment and creating a practical workflow example.

Requirements:

  • Ensure that Node-RED is installed and running on your RevPi device. If you are using the Full Image, Node-RED is pre-installed; You only need to enable the Node-RED service in PiCtory.

Node-RED Service activation
  • You should be aware of the IP address of your RevPi for proper communication.

  • Your RevPi module should already be configured using PiCtory.

Implementation

Create a PiCtory Configuration

  • Drag and Drop the Revpi Connect/+/S

Don’t forget to save and reset driver to apply your configuration

Create a Flow

In this example, we will create a flow to switch an LED (LED A1 on/off) on the RevPi.

  • Start Node-RED

You have two possibilities to start Node-RED.

  1. By typing the IP address of your RevPi on the web browser: <Ip-address>:1880. For example: 192.168.1.xxx:1880

  2. Open PiCtory after activating the Node-RED service. In the Menu Apps, you will be able to see Node-RED. Just click on start

  • Install the palette “node-red-dashboard” like show in the video below. For This example, it was already installed.

  • Drag two "Button" nodes into the flow: one for turning the LED on and one for turning it off.

  • Double-click on a "Button" node to open the "Edit button node" window. Here, you can specify the action for the button. In this example, set it to switch the LED on and add the button to the "On" group.

  • Click "Update," and you can rename the button if desired. Then, click "Done."

  • Repeat the same process for the other "Button," configuring it to switch the LED off.

  • Next, drag two "Exec" nodes into the flow. Double-click on each "Exec" node to open the "Edit exec node" window, where you can input the processing commands. For example, use "piTest -w RevPiLED,1" in one "exec node" and "piTest -w RevPiLED,0" in the other "exec node."

  • Lastly, add a "Debug" node to the flow and connect the nodes as shown in the picture below.

Here is the flow file for this example:

You can copy the file flows.json to your RevPi device, for example, to /home/pi/.node-red/.

Use the following tutorial to know how to copy a file to a RevPi.

Note that if you copy the flows.json file to your RevPi, you might be missing some nodes. In that case, you'll need to install the missing palette for nodes as shown in the provided video.

Click on “Deploy” to create the application

Test

For testing the application, you must use Node-RED Dashboard. Node-RED Dashboard by typing the following address on your web browser: <Ip-address>:1880/ui. For example: 192.168.1.xxx:1880/ui

Now you can enjoy your App !