Makers Blog Archive

How to send a mail via Node-Red

mschneider 21 February 2019 min. read
287 views 0 comments

To be able to follow this blog, you must have alreday installe the OPC-UA inside Node-Red.

Then, it will be possible to send a mail, with a command from the PLC (xSend) including a variable message (strText).

Here are the 2 variables of the AXC F 2152 which will be used and accessible by OPC UA :

1

OPC option must be checked.

In the Node-Red flow, insert this code :

2

The ‘debug’ output are just for help.

First, you need to access to the OPC variables, and scan each 5 seconds their value.

3

Wait for the OPC UA server responses :

4

To get the value of xSend

5

If xSend = True, extract the strText

6

Then send the message to a defined mail adress :

7

Of course, you have to adapt the name of the server, mail adress, etc…

Then, you will just need to define the text to send in strText in the AXC F 2152 and set xSend to TRUE.

It is of course necessary to reset xSend. For this, the second part of the flow is used :

Cyclically, set xSend to FALSE :

8

Send the value to the OPC UA server :

9

10 permit to control the write process.

10permits to send the mail from Node-Red, for test, for example. It sets xSend to TRUE.

Here is the code of the flow for firmware v1.x (click the triangle).With the new firmware version 2019.0, it is now impossible to write a value from node-Red to an OPC UA OutPort.So, here is a new flow using xSend and xSent as variables to send the mail and to inform the AXC F 2152 that the mail has been sent (click the triangle).

Note:

The Makers Blog shows applications and user stories of community members that are not tested or reviewed by Phoenix Contact. Use them at your own risk.

Discussion

Please login/register to comment

Login/Register

Leave a Reply

Newsletter
Never miss a new article
Sign up for the newsletter
Never miss news about PLCnext Technology
Get interesting content via newsletter four times a year
Receive exclusive information before all other users