Raspberry Pi Automation
The industrial Raspberry PLC, an open-source PLC Raspberry Pi 4, has multiple applications in the industrial environment for automation solutions and industrial control, as its inputs and outputs allow the companies millions of possibilities.
In this post, you will learn how to send emails using Node-RED with a Raspberry Pi based PLC. Node-RED is a very useful open-source software, which allows us to monitor alarms and send notifications when needed.
Either Ethernet cable or HDMI cable with monitor
The Raspberry Pi industrial PLC from Industrial Shields comes with the Node-RED already installed. But in case you do not have it, install it from here.
1. First of all, let's connect to your Raspberry Programmable Logic Controller either through SSH or through HDMI.
2. Then, you have to get into Node-RED. If you are connected through SSH, just type the IP address in your favorite browser:
Otherwise, just open the browser and go to localhost:1880.
There are many possibilities for the origin of the values, so the values coming from any input of the Raspberry PLC are allowed. This tutorial is really useful if you just get a value from any input coming from your industrial environment, and take its value.
For example, run the get-analog-input script that we provide with the Raspberry PLC images, and get the value of input I0.7 like this:
As this is a very easy tutorial, you are going to take three random values coming from inject nodes, so that we can play with those values.
3. So, let's add three inject nodes with three values, for example 21, 22, and 23 to the Node-RED flow, to send an email if the value is higher than 22.
4. Now, add a switch node to get the value if is higher than 22 like this:
5. You will need an email node to send the messages, so let's go to the right top menu > Manage Palette > Install > Type: node-red-node-email and install,
As you can see in the picture below, this node needs a msg.topic, msg.to and msg.from to send an email.
6. So the next step will be to add msg.topic, msg.to and msg.from to the change node.
7. Finally, add an email node, configure it with your user, password and server, and wire it.
8. Deploy changes, run the three inject nodes, and check your email!
If you are a Gmail user, you will probably get an error message. You can visit this
Now, learn more and see