Example RevPi with CODESYS and Node-RED

In this example, we demonstrate the exchange of I/O data between the RevPi CODESYS application and an external Node-RED application using a RevPi virtual device.

We run CODESYS Control for Raspberry Pi MC SL and Node-RED RevPi Nodes Server on a RevPi Connect+ or Connect S.

The CODESYS application consists of a virtual RevPi device with 32 byte inputs and outputs that exchanges data with a Node-RED application using noderedrevpinodes-server.

    • Log in to RevPi Status via the web browser.
    • Select the “Services” tab.
    • To enable Node-RED and the Node-RED RevPi Nodes Server, select the checkbox in front of the “Enabled” entry.
    • To save the settings, select the “Save all” button.

    • Select the “Apps” tab.
    • To open the Node-RED dashboard, select the “Start” button for Node-RED.

The Node-RED dashboard opens.
If your web browser and Node-RED are installed on the same terminal, you can access Node-RED using the URL http://localhost:1880.
If your web browser and Node-RED are installed on different terminals, you must use the IP address of the computer on which Node-RED is installed: http://<ip-address>:1880.

    • Select the “Manage palette” menu item.

    • Select the “Install” tab.
    • Enter “node-red-dashboard” in the search.
    • Select the “install” button for the “node-red-dashboard” node.

    • Select the “Nodes” tab.

Here are some nodes visible that you can use to create a real-time data dashboard.

  • Select the “Import” menu item.

  • Select the button “select a file to import” and open the file “RevPi CODESYS Node-RED.json” from the “Examples” directory.
  • To create the project as a new flow, select for “Import to” the “new flow” button.
  • Select the “Import” button.

  • To launch the application on the Node-RED server, select the “Deploy” button.

  • Create the RevPi CODESYS Node-RED project from the “Examples” directory and download it to the RevPi Connect running CODESYS Control and Node-RED RevPi Nodes Server.

The CODESYS application writes values [1 … 32] into the 32 input bytes of the virtual RevPi device via the 32 byte outputs of Q_Virtual. The Node-RED application reads the corresponding 32 input bytes from the address space of the virtual RevPi device and writes them back to the output address space of the virtual RevPi device. The values are then visible in CODESYS online mode under I_Virtual inputs in the “Revolution PI Virtual Device I/O Mapping” tab.

The Node-RED application displays the connection status and value next to each “revpi-getpin”.