In this series, we will demonstrate how easy it is to create Pi-Plate applications using Node-RED. What is Node-RED? On their website, nodered.org, the authors describe it as:

Node-RED is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways. It provides a browser-based editor that makes it easy to wire together flows using the wide range of nodes in the palette that can be deployed to its runtime in a single-click.

Before starting, this tutorial requires either a TINKERplate, DAQCplate, or DAQC2plate. In addition you should have already set up your Raspberry Pi to use Pi-Plates by applying all the steps on the Getting Started page. If your setup is ready then we can dive in! First, Node-RED has to be installed on your Raspberry Pi. If you are using a Raspberry Pi model 4 or older with the Bullseye OS then you can install it by clicking on the Raspberry Pi logo on your desktop and selecting Preferences --> Recommended Software --> Programming --> Node-Red:

If you are using a Raspberry Pi Model 5 running Bookworm, you will have to install the Pi-Plate python modules by opening a terminal window and executing this command:
pip install --break-system-packages Pi-Plates

After that, run the following command to install the latest version of Node-RED:
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)

After, installation, the next step is to launch Node-RED. To do this, open a terminal window, type "node-red-start" at the command prompt, and hit <ENTER>. Some text will appear on your screen that includes additional tips on starting and stopping Node-RED as well as a couple of IP addresses. Use these addresses in a browser to access the Node-RED editor. The first one (http://192.168.4.113:1880 on my network), let's you access the editor with another computer. The second one, http://127.0.0.1:1880, let's you access the editor using the browser on the Raspberry Pi. For convenience, we always use a remote PC to access the editor since the Chromium browser on the RPi is a little sluggish. Whichever way you prefer, open the browser on your PC, type one of the URLs into the address window, and hit <ENTER>. The Node-RED editor will then appear on your screen:

 

The next step is to add the nodes that connect to the Pi-Plates. Click on the "hamburger" on the upper right corner of the screen then click on "Manage palette" on the dropdown menu:

 

After the the menu pops open on the left, click the "Install" tab and enter "Pi-Plates" into the search window. Click the "install" button on the "node-red-contrib-pi-plates" palette:

 

You may have to return to the command prompt on the RPi and restart Node-RED after the above step. Once done, scroll down the list of nodes on the left of the editor and you should find the Pi-Plate nodes:

We can now create our first flow. Since we already have the Pi-Plates nodes in front of us, drag an ADC node onto the editor work space:

The red triangle is an error symbol and the blue circle means that the node has not been deployed yet.  To eliminate the error we have to configure the node by double clicking it and adding some information to the pop out configuration page on the right. In our case, we selected the DAQC2plate located at address 0,  named the node "Analog Input 1," and chose Channel # 0 from the dropdown menu. Click "Done" when your node is configured and note that the TINKERplate and the DAQCplate will show a similar set of options:

At this point, you can click the "Deploy" button on the upper right corner of the editor and start your flow. But, there's really nothing happening because the ADC node needs to be triggered to pull data from the DAQC2plate. So let's scroll to the top of node list and drag an add an "inject" node to the left of the ADC node. Next, route a wire from the connection on the right side of the inject node to the connector on the left side of the ADC node:

Next, double click the inject nide to bring up its menu. Use the drop down menu to set the message payload to boolean-true and set te timing parameters as displayed below:

After you click Deploy, the voltage being measured by the DAQC2plate will be displayed and updated once a second below the ADC node:

That concludes this lesson where you:

  1. Installed Node-RED
  2. Imported the Pi-Plates palette
  3. Created and ran your first flow.

A big shout out to Mike Harsh for creating the Node-RED palette for the Pi-Plates

Series NavigationNode-RED and Pi-Plates - Adding a Dashboard >>
1 Comment
  1. Thank you for Pi-Plates Jerry and the documentation you provide! Great stuff!

Comments are closed.