Introduction
Raspberry Pi automation
Can you imagine receiving an alarm from your industrial Raspberry Pi PLC to your phone via WhatsApp in real time?
That is possible because of the Open-Source Raspberry Pi 4. So in this tutorial, we are going to teach you how to develop a very simple low-code program using Node-RED for an open source PLC programming, so that you can be more competitive by streamlining your business processes.
Related links
Node-RED
Setting an alarm with a Raspberry Pi industrial PLC can be a very useful functionality to take control of your industrial environment. With our Open-Source Hardware, you will be able to get WhatsApp messages and take control of your company.
The first thing we need to do is to open the Node-RED from our Raspberry PLC. Install it if you do not have it yet from here.
As we can access either through SSH or HDMI, we will open our browser and just type:
localhost:1880 <--- If you are connected through HDMI
or
YOUR-IP-ADDRESS:1880 <--- If you are connected through SSH.
Once you are into Node-RED, let's develop our alarm application using WhatsApp!
Node-red-contrib-whatsapp-cmb
As we are going to use the node-red-contrib-cmb nodes from Node-RED to develop our alarm system for industrial control, we first need to install the nodes.
1. So, once in Node-RED go to the top right hamburger menu > click on Manage Palette > Install > Type:
node-red-contrib-whatsapp-cmb
and install it.
2. If you go to the filter nodes search bar, and search 'WhatsApp', you will see a new green node called Send Message. Drag and drop the node to the flow, and double click to explore it.
Getting inputs
This application can be applied for multiple purposes and inputs can come from different places. The Raspberry PLC from Industrial Shields, as you can see here, can have up to 36 inputs. That is perfect for our application, as we could get the values like this:
5. Add three inject nodes with sample values, like 21, 22 and 23 to send a WhatsApp message as a temperature alarm if the value is higher than 22.
6. Now, add a switch node to get the value if is higher than 22 like this:
7. Then, add a change node and set the msg.payload to the message you want to be sent to your WhatsApp.
8. Finally, wire the Send Message node to the change node, and add a debug node to get the debug messages.
9. Inject the 21, 22 and 23 messages, and get your alarm in your phone!
How to send WhatsApp messages with an industrial Raspberry PLC