How to send WhatsApp messages with an industrial Raspberry PLC

Node-RED tutorial: Develop your alarm application with Raspberry PLC for industrial automation
July 2, 2021 by
How to send WhatsApp messages with an industrial Raspberry PLC
Boot & Work Corp. S.L., Fernandez Queralt Martinez

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

How to

Connect an industrial Raspberry PLC to Wi-Fi

Read 

Raspberry PLC

Family products

See 

How to

Find your perfect industrial Programmable Logic Controller

Read 

Basics about

Raspberry Pi based PLC Analog Outputs

Read 

Touchberry Pi

Family products

See 

How to

Program a Raspberry Pi PLC Interrupt inputs with Python

Read 

Requirements

  • Raspberry PLC
  • Either Ethernet cable or HDMI cable with an extra monitor.

Explanation

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.

3. If any field of a Node-RED node is red, means that it must be configured. As the account field is red, click on the pen to edit.

The properties' configuration node will be displayed. You will need to fill in your phone and API-KEY. Follow the steps from here  to create an API-KEY.

4. Once the API-KEY is created and you can interact with the WhatsApp Bot, it is very easy to test the example. First, fill in your phone and API-KEY in the Send Message node and leave it configured.

Node-red-contrib-whatsapp-cmb - Node-RED tutorial: How to send WhatsApp messages

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:

Getting inputs 1 - Node-RED tutorial: How to send WhatsApp messages with an industrial Raspberry PLC

Even though it is a very simple way of getting a value from an input, we are going to do it easier with inject nodes.

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.

Getting inputs 2 - Node-RED tutorial: How to send WhatsApp messages with an industrial Raspberry PLC

6. Now, add a switch node to get the value if is higher than 22 like this:

Getting inputs 3 - Node-RED tutorial: How to send WhatsApp messages with an industrial Raspberry PLC

7. Then, add a change node and set the msg.payload to the message you want to be sent to your WhatsApp.

Getting inputs 4 - Node-RED tutorial: How to send WhatsApp messages with an industrial Raspberry PLC

8. Finally, wire the Send Message node to the change node, and add a debug node to get the debug messages.

Getting inputs 5 - Node-RED tutorial: How to send WhatsApp messages with an industrial Raspberry PLC

9. Inject the 21, 22 and 23 messages, and get your alarm in your phone!


Get your alarm in your phone - Node-RED tutorial: How to send WhatsApp messages with an industrial Raspberry PLC

Now, would you like to learn how to send emails from your Raspberry Pi PLC controller?

​Search in our Blog

How to send WhatsApp messages with an industrial Raspberry PLC
Boot & Work Corp. S.L., Fernandez Queralt Martinez July 2, 2021
Share this post

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 >>>