Node-RED Tutorial: How to read digital inputs from Raspberry PLC
The digital inputs of an industrial Raspberry PLC for Raspberry Pi automation.
24 August, 2021 by
Node-RED Tutorial: How to read digital inputs from Raspberry PLC
Boot & Work Corp. S.L., Fernandez Queralt Martinez

Introduction

For some time now, Industrial Shields® has been using Node-RED as it is a very powerful programming tool for developing all kinds of applications for open source and industrial automation. So we have decided to create Industrial Shields® official nodes of Node-RED for you to use the inputs and outputs in a very easy way.

In this post, we will learn how to use the digital read node for Raspberry Pi PLC.

Related Links

Node-RED tutorial

How to set

Digital outputs to Raspberry PLC

How to read

Analog inputs from Raspberry PLC

How to set

Analog outputs to Raspberry PLC

Requirements

Installation

  • Install Node-RED  in your Raspberry Pi based PLC, if it is not yet.

  • Install the node-red-contrib-rpiplc-node nodes. There are two ways:

    • In Node-RED, go to Menu - Manage palette - Install - search for node-red-contrib-rpiplc-node - Install.

    • In a terminal window, go to the ~/.node-red directory and run the following command:
      npm i node-red-contrib-rpiplc-node

Industrial Shields Nodes

Once the nodes are downloaded, you will be able to see the four nodes in the nodes section, as shown below:

Industrial Shields Nodes - Node-RED Tutorial: How to read digital inputs from Raspberry PLC

Digital Input Node

In this post, we will focus on the digital read node, which is an input node for reading the Raspberry Pi industrial PLC digital input pins.

So, drag and drop the node to the flow, double-click and add a new Raspberry Pi PLC controller configuration by clicking on the pen.

Then:

  1. Select the model of the Raspberry PLC.

  2. Click on Add.

  3. Select and input.

  4. Wire a debug node after the digital read node to get the value. And an inject node before the node to start getting the value.

  5. Physically, connect 24V to the I0.5 input to turn on the LED and get a 1 digital value.

  6. Add an analog-read node, and get the resolution with a debug node.

As we can see in the picture below, this is how we will get the result:

Digital Input Node - Node-RED Tutorial: How to read digital inputs from Raspberry PLC

Dashboard

In order to control the data graphically, we are going to add a Dashboard widget and request the temperature every 2 seconds to monitor it with the open source PLC Raspberry Pi.

  1. In the inject node, select the option: Inject once after 0.1 seconds, then repeat: Interval every 2 seconds.

  2. Add a gauge node after the digital-read node.

    1. Add a new ui_group and a new ui_tab.

    2. Select 6x5 size.

    3. Select your prefered type, in our case "Level".

    4. Change the label for the input name

    5. Set the range between 0 and 1

    3. Go to your dashboard and monitor your input!

    [{"id":"f5e89d62.2ca78","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"ac4ab640.7daf98","type":"rpiplc-digital-read","z":"f5e89d62.2ca78","rpiplc":"9a660914.ca7488","pin":"I0.5","name":"","x":420,"y":160,"wires":[["b8859091.b1ec6","64fac913.dab2f8"]]},{"id":"db0d26d4.246ce8","type":"inject","z":"f5e89d62.2ca78","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":260,"y":160,"wires":[["ac4ab640.7daf98"]]},{"id":"b8859091.b1ec6","type":"debug","z":"f5e89d62.2ca78","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":530,"y":220,"wires":[]},{"id":"64fac913.dab2f8","type":"ui_gauge","z":"f5e89d62.2ca78","name":"","group":"33d04b74.74e3e4","order":0,"width":"6","height":"5","gtype":"wave","title":"","label":"","format":"{{value}}","min":0,"max":"1","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":570,"y":160,"wires":[]},{"id":"9a660914.ca7488","type":"rpiplc-config","model":"RPIPLC_57R","name":""},{"id":"33d04b74.74e3e4","type":"ui_group","name":"Default","tab":"9882cc2c.3cb1d","order":1,"disp":false,"width":"6","collapse":false},{"id":"9882cc2c.3cb1d","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}

Flow 1 - Node-RED Tutorial: How to read digital inputs from Raspberry PLC
Dashboard - Node-RED Tutorial: How to read digital inputs from Raspberry PLC
Node-RED Tutorial: How to read digital inputs from Raspberry PLC
Boot & Work Corp. S.L., Fernandez Queralt Martinez
24 August, 2021
Share this post
Archive

Looking for your ideal Programmable Logic Controller?

Take a look at this product comparison with other industrial controllers Arduino-based. 

We are comparing inputs, outputs, communications and other features with the ones of the relevant brands.


Industrial PLC comparison >>>

Do you want more information?

Just fill the form!

Tell me more!