At Industrial Shields ®, we love developing all kind of applications with Node-RED, which is a powerful programming tool for the open-source industry.
In this blog, we will learn how to read analog inputs from our Raspberry PLC using Node-RED.
Either Ethernet or HDMI cable with an external screen to connect to your Raspberry PLC.
First of all, make sure you have Node-RED rightly installed: Know how >>
Then, there are two ways of installing the node-red-contrib-rpiplc-node:
1. To install the stable version use the Menu - Manage palette - Install option and search for node-red-contrib-rpiplc-node
2. Go to your /home/pi/.node-red directory, and run the following command:
npm i node-red-contrib-rpiplc-node
INDUSTRIAL SHIELDS NODES
Once the Industrial Shields ® nodes are successfully installed, you will see four nodes in the nodes section:
In this blog, we will test the analog read node.
ANALOG READ NODE
The analog read node is an input node for reading the Raspberry PLC analog input pins.
Drag & drop the node to the flow, double-click and add new Raspberry PLC configuration by clicking on the pen.
Just select the model of the Raspberry PLC, click on Add and select an input. Optionally, type a name for this node.
Now, wire an inject node before the analog read, and add a debug node to get the analog values.
Physically, we connect a wire from the 5V to the I0.2 input, and then, we disconnect it.
As we can see, this is how we get the result.
Optionally, double-click on the inject node, click on the check button to "inject once after 0.1 seconds, then" and repeat -> select interval every 3 seconds, for example.
After the analog read node, add a gauge Dashboard node. Edit it and add new ui_group and new ui_tab. Select a sample size, like 6x5. And set the range between 0 and 2048.
Edit the parameter you want, save changes and deploy. Go to your dashboard either through the menu or add a /ui in your URL after the 1880 like: localhost:1880/ui and control your temperature!