Sending email messages from the PLC sounds like an easy task. However, very few applications do this on the production floor. This is probable due to the networks involved and using authentication can be complicated. In our example we will use a restricted Gmail SMTP server so no authentication will be required. We will walk through sending email and text messages from the PLC to Google Gmail. Once in your Gmail account, the message can be automatically forwarded to another verified email or SMS text message address.
The BRX Series PLC also has this Email capability along with attaching files. Let’s get started.
Previously in this BRX series PLC we have discussed:
System Hardware – Video
Unboxing – Video
Installing the Software – Video
Establishing Communication – Video
Firmware Update – Video
Numbering Systems and Addressing – Video
First Program – Video
Monitoring and Testing the Program – Video
Online Editing and Debug Mode – Video
Timers – Video
Counters – Video
High Speed IO – Video
Compare Instructions – Video
Math Instructions – Video
Program Control – Video
Shifting Instructions – Video
Drum Instruction – Video
Serial Communication – Modbus RTU to Solo Process Temperature Controller – Video
Data Logging – Video
Simple Mail Transfer Protocol (SMTP) is an internet standard for email transmissions.
Google provides three different SMTP settings in which you can send email messages from a printer, scanner or application (PLC).
1. SMTP relay service – used to send mail from your organization by authenticating with the IP address(s). You can send messages to anyone inside or outside of your domain.
2. Gmail SMTP server – requires authentication with your Gmail/Google Apps account and password. Messages can be sent to anyone inside or outside of your domain.
3. Restricted Gmail SMTP server – does not require authentication, and you will be restricted to send messages to Gmail or Google Apps users only.
We will use restricted Gmail SMTP server to send emails and text messages. This is located at aspmx.l.google.com. This does not require authentication so a greater number of PLC’s will be able to communicate to the server.
If you do not have a Google Gmail Account then you will need to set up this free service. Google Email Account
BRX Series PLC Setup
Now start the Do-more Designer software. This is available free of charge and is a fully functional package complete with a simulator. The BRX Series PLC has an Ethernet connection on board We will ensure this is connected to the internet.
Start a new project or an existing project that has connection to the internet.
Under ‘Project Browser’: ‘Tools’ select ‘System Configuration’
In ‘CPU Configuration’ verify the IP address and Net Mask.
Hit the “Configure…” button. The gateway address is now shown. This is the address to the intranet that needs to be set.
We will now set up our email device that will be used in our PLC instructions. In ‘System Configuration’ select ‘Device Configuration’
Select “New Device” (If you do not already have a SMTP Client (Email) configured. If you do then select it and hit “Edit Device”)
Select ‘SMTP Client (Email)’ and hit ‘OK’
Beside the ‘Device Name’ enter a name for the Email Client. Ex: @Email Beside the ‘SMTP Server IP Address’ hit the ‘DNS Lookup…’
Beside the URL: enter the server address aspmx.l.google.com and then hit ‘Lookup’. This will retrieve one of the IP addresses of the server. Then press ‘Select’ to return this address to the configuration page.
Ensure that the SMTP Server Port is set for 25. This is the default port setting. The Timeout setting can be left at 30 seconds. This is the amount of time for the PLC to wait before setting any error message. Enter your ”‘From’ Email Address” – Enter your Google Gmail account address. Select ‘OK’ to end the configuration. Ensure that authentication is disabled.
Now that we have our email client device ‘@Email’ set up we can move onto programming the Email messages.
We use the EMAIL instruction in the PLC to send the messages. We will send our message with a file attachment. Here is the instruction.
SMTP Device: This is set for the device that we just set up. (@Email)
To: We must select this and enter a valid gmail email address. Notice that this is in quotation marks. Optional items are for Cc (Carbon Copy) and Bcc (Blind Carbon Copy)
Select “Automatically insert space after each term”. This will insert a space after each variables in the message.
Message: This message can be a maximum of 1023 characters. All text strings will be in double quotes. All variables will be written without quotes. In our example we have the following:
“The file contains the log of memory location V0. It currently is: “V0
Notice in the message we combine text with actual word and bit addresses that we want to send. The help function in the Do-more Designer software can provide further information.
This is where we can attach a file to send with the email. We have discussed this previously in the following post:
BRX Series PLC Data Logging – Video
You must be specific on the location of the file and the name of the file to be sent. If the location or file name is incorrect, then a file with “Error Opening Attachment” will be sent.
We will select “Delete File after EMail Sent”. This will erase the file every time the email is sent.
On Success – This will set a bit if the email message is sent. (C0)
On Error – This will set a bit if the email message was not sent. (C1)
Here is the instruction in our ladder logic. You will notice that the instruction itself has a built in one shot. This is the triangle indication on the instruction.
Here is the rest of our ladder logic. This will increment V0 every second. It will also use the FILELOG instruction to log V0 every second.
Running the program and triggering the messages will send the Email to your google account. The email will automatically go to your spam folder. This is because authentication is turned off. In order for the email to go to your inbox and forward the message as a text (SMS) message we need to set up a filter.
Under the gear sign in Google Gmail select the ‘Settings’.
Select ‘Create a new filter’ or if you already have one select the edit button beside the filter.
Under the subject we will add the title “BRX Series PLC Email with Attachment”. The filter will see this email subject and trigger the actions to follow.
“Never send it to Spam” selection will ensure that the email will go to your inbox.
A dialogue to select forward Email to a specific account. During this process a verification code will be sent to this address. You must enter this code for validation or respond to the Email in order for the forwarding address to work.
Email to SMS Gateways can be used to forward your message in a text format. Here is a website that will show a List of Email to SMS Gateways.
Here are some that we use in Canada: Example: 613-451-0104 on Rogers network = email@example.com
Once we have the forwarding address in and verified, we can select Update or Save Filter.
Running the program and triggering the Email instruction will sent the email to our gmail inbox.
Opening the message we can see the attachment.
Clicking on the MyFileLog.CSV file will show you the contents of the file. You will see the date and time along with the value of register V0.
Our filter also forwarded this to our cell phone using SMS. Here is the same message:
In the above example we used a restricted Gmail SMTP server. No authentication was required so we can send email with only an internet connection to the PLC. See the video below to see the BRX Series PLC Send Email and Text (SMS) Messages.
You can download the program here.
BRX Series PLC from Automation Direct – Power to deliver
Overview Link (Configure and purchase a system)
Manuals and Product Inserts (Installation and Setup Instruction)
Do-More Designer Software v2.0.3 (Free Download Link) – The software will contain all of the instruction sets and help files for the BRX Series PLC.
Next time we will look at communication to the BRX PLC using AdvancedHMI. (Modbus TCP Protocol)
Watch on YouTube : BRX PLC Email – Text SMS Messaging Gmail
If you have any questions or need further information please contact me.
If you’re like most of my readers, you’re committed to learning about technology. Numbering systems used in PLC’s are not difficult to learn and understand. We will walk through the numbering systems used in PLCs. This includes Bits, Decimal, Hexadecimal, ASCII and Floating Point.
To get this free article, subscribe to my free email newsletter.
Use the information to inform other people how numbering systems work. Sign up now.
The ‘Robust Data Logging for Free’ eBook is also available as a free download. The link is included when you subscribe to ACC Automation.