In compliance with high industry standards

Browse our Blog. You will find multiple applications, solutions, code examples. Navigate using the tag cloud or search using specific criteria

How to send Emails using Raspberry PLC

Node-RED tutorial: learn how to take control of alarms using Node-RED

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 blog, we 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 will allow us to monitor alarms and send notifications when needed.

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

Related Links

How to connect a
Raspberry Pi PLC 
controller to Wi-Fi



Read >>

 

Basics about the industrial Raspberry Pi PLC
Analog outputs


Read >>



How to find your
perfect industrial PLC for 
industrial automation



Read >>

How to program the Raspberry Pi industrial PLC 
Interrupt inputs with Python


Read >>

Raspberry Programmable Logic Controller
family products


Read >>

TouchBerry Pi
family products for 
industrial control



Read >>

Requirements

 Raspberry PLC

 Either Ethernet cable or HDMI cable with monitor

Node-RED

The Raspberry 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, we are going to connect to our Raspberry PLC either through SSH or through HDMI.


2. Then, we 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, we 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.  We 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 we 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! 

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

 

Looking for your ideal PLC?

Take a look at this product comparison with other industrial controllers Arduino.

We are comparing inputs, outputs, communications and other features with the ones of the relevant brands.


Industrial PLC controller comparison >>

Do you want more information?

Just fill the form!

Tell me more!