How to send Emails using Raspberry PLC
Node-RED tutorial: learn how to take control of alarms using Node-RED
1 July, 2021 by
How to send Emails using Raspberry PLC
Boot & Work Corp. S.L., Fernandez Queralt Martinez

Introduction

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.

Related links

How to

Connect a Raspberry Pi PLC controller to WI-FI

Read 

Raspberry PLC

Family products

See 

How to

Find your perfect industrial PLC for industrial automation

Read 

Basics about

The industrial Raspberry Pi PLC Analog outputs

Read 

Touchberry Pi

Family products

See 

How to

Program the Raspberry Pi PLC Interrupt inputs with Python

Read 

Requirements

 Raspberry PLC

 Either Ethernet cable or HDMI cable with monitor

Node-RED

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:

https://10.10.10.30:1880

Otherwise, just open the browser and go to localhost:1880.

https://localhost:1880
Node-RED - Node-RED tutorial: How to send Emails using Raspberry PLC

Sending emails

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:

get-analog-input example - Node-RED tutorial: How to send Emails using Raspberry PLC

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.

Inject nodes to send an email if the value is higher than 22 - Node-RED tutorial: How to send Emails using Raspberry PLC

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

Switch node if value is higher than 22 - Node-RED tutorial: How to send Emails using Raspberry PLC

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.

Email node - Node-RED tutorial: How to send Emails using Raspberry PLC

6.  So the next step will be to add msg.topic, msg.to and msg.from to the change node.

Add msg.topic, msg.to and msg.from to the change node - Node-RED tutorial: How to send Emails using Raspberry PLC

7.  Finally, add an email node, configure it with your user, password and server, and wire it.

Add email code - Node-RED tutorial: How to send Emails using Raspberry PLC

 

8.  Deploy changes, run the three inject nodes, and check your email! 

Temperature Alarm - Email - Node-RED tutorial: How to send Emails using Raspberry PLC

Troubleshooting

If you are a Gmail user, you will probably get an error message. You can visit this website to know more about it.


 Now, learn more and see
How to send WhatsApp messages from Raspberry PLC using Node-RED! >>>

 

How to send Emails using Raspberry PLC
Boot & Work Corp. S.L., Fernandez Queralt Martinez
1 July, 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!