Categories
Articles Communication Do-More Do-More Designer PLC PLC Learning

Here’s is a way to send email text messages PLC

Sending email messages from the PLC sounds like an easy task. However, very few applications do this on the production floor. This is probably 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.
Here’s is a way to send email text messages PLC


Note:
Google is removing “Less Secured Apps” in the mail app. (Gmail) If you are using this to send email from your controller, you must enable 2-step verification. This will then give you the option to generate an “App Password” for your controller or program.
Gmail Less Secure App Access – App Passwords

SMPT – Google – PLC Send Email Text Messages

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.
Restricted Gmail SMTP Server – PLC Send Email Text Messages

We will use a 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 PLCs 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

Now start the Do-more Designer software. This is available free of charge and is a fully functional package complete with a simulator. We will be using the simulator for our example. The actual Do-More PLC will have to have an Ethernet connection onboard connected to the internet. (H2-DM1E)

System Configuration – PLC Send Email Text Messages

Start a new project with the simulator or an existing project that has a connection to the internet.

Under ‘Project Browser’: ‘Tools’ select ‘System Configuration’
Here’s is a way to send email text messages PLC

In ‘CPU Configuration’ verify the IP address and NetMask. This will be automatically populated when using the Do-more Simulator.
Here’s is a way to send email text messages PLC

Hit the “Configure…” button if the IP address needs to be modified.
Here’s is a way to send email text messages PLC

In ‘System Configuration’ select ‘Device Configuration’
Here’s is a way to send email text messages PLC

Select “New Device” (If you do not already have an SMTP Client (Email) configured. If you do then select it and hit “Edit Device”)
Here’s is a way to send email text messages PLC

Select ‘SMTP Client (Email)’ and hit ‘OK’

Beside the ‘Device Name’ enter a name for the Email Client. Ex: @MyEmailClient Beside the ‘SMTP Server IP Address’ hit the ‘DNS Lookup…’
Here’s is a way to send email text messages PLC

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.
Here’s is a way to send email text messages PLC

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. Here’s is a way to send email text messages PLC
Ensure that authentication is disabled.

Now that we have our email client device ‘@MyEmailClient’ set up we can move onto programming the Email messages.
Here’s is a way to send email text messages PLC

Ladder Logic Program – PLC Send Email Text Messages

We use the EMAIL instruction in the PLC to send the messages. We will send two messages; one will be an email and the other an SMS text message. The subject line will be different to distinguish the two.

Here is the PLC program for sending both messages.
Here’s is a way to send email text messages PLC

You will notice that the messages are triggered by a one shot.
Here’s is a way to send email text messages PLC

Do-More Prog12 GMail Text
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.


Testing the Program – PLC Send Email Text Messages

Running the program and triggering the messages will send the Email to your google account.
Gmail 01 Email

You will notice if you open the message, a warning is given. ‘This message may not have been sent by’ appears because authentication is turned off. We can just ignore this message.
Gmail 02 Email Message

We need to now set up the Email forwarding to any account.

Under the gear sign in Google Gmail select the ‘Settings’.
Gmail 03 Email Settings

Select ‘Add a forwarding address’
Gmail 04 Add a forwarding address

This will bring up a dialogue to now 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.
Gmail 05 Add a forwarding address

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 = 6134510104@sms.rogers.com

  • number@txt.bellmobility.ca
  • number@sms.wirefree.informe.ca
  • number@sms.fido.ca
  • number@msg.telus.com
  • number@sms.lynxmobility.com
  • number@text.mtsmobility.com
  • number@mobiletxt.ca
  • number@sms.rogers.com
  • number@sms.sasktel.com
  • number@vmobile.ca
  • number@txt.windmobile.ca
  • number@sms.wirefree.informe.ca

Once we have the forwarding address in and verified, we can move onto the last step, which is creating a filter. The filters will allow automatically look at the incoming Email message and perform an action on the message. In our case, we will be forwarding the message.

Under the settings menu, select ‘Filters’ and then ‘Create New Filter’
Gmail 06 Settings Filters

The first page contains the items that we are looking for in the filter. Fill in the address of the sender, which will be our Gmail account and the subject. The subject will be ‘ACC PLC _ GMail Text’.
Gmail 07 Settings Filters

Select ‘Continue >>’

Our filter parameters appear at the top of the screen. Now we can determine what to do when a message arrives.
Gmail 08 Settings Filters

  • Mark as read
  • Forward it to (Select forwarding address)
  • Never send it to Spam

You can create as many filters as you wish. Sending to multiple accounts requires only to repeat the filter with the additional email addresses.

In the above example, we used a restricted Gmail SMTP server. No authentication was required so we can send an email with only an internet connection to the PLC.

Watch on YouTube: Here’s is a quick way to send email text messages from the PLC

If you have any questions or need further information please contact me.
Thank you,
Garry



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.


Categories
Articles Communication PLC Learning

How to Send Email to SMTP Server (VB6)

Simple mail transfer protocol (SMTP) is the email protocol for sending information. We can take advantage of this ability to email from our data logged from the PLC. Shift reports on productivity can be automatically emailed to recipients. Faults or errors detected by the PLC can be emailed directly to individuals for correction.


Note:
Google is removing “Less Secured Apps” in the mail app. (Gmail) If you are using this to send email from your controller, you must enable 2-step verification. This will then give you the option to generate an “App Password” for your controller or program.
Gmail Less Secure App Access – App Passwords

Send Email to SMTP Server

We will use visual basic 6 (VB6) to send an email message to the SMTP Google Gmail server. Using this method we can use HTML code to format our messages. Attachments can also be added to the email message. In this example, I have added the ACC icon file.

Add Microsoft CDO for Windows 2000 Library

The first step is to add a reference to Microsoft CDO for Windows 2000 Library.  Project -> References CDO References SMTP Email

Make a simple form:
Form SMTP Email
This will have one command button on it labeled “Send Mail”

The code for the command button will be as follows:
Private Sub Command1_Click()

Call SendEmail
End Sub

Add the following Sub SendEmail code to the project :
‘Sample code that is used to send emails from any SMPT server using CDO in Visual Basic 6.0.

‘Added a reference to the project by navigating to Project -> references and adding Microsoft CDO for windows 2000 Library.
Sub SendEmail()
On Error Resume Next ‘ Set up error checking
Set cdoMsg = CreateObject(“CDO.Message”)
Set cdoConf = CreateObject(“CDO.Configuration”)
Set cdoFields = cdoConf.Fields
‘ Send one copy with Google SMTP server (with autentication)
schema = “http://schemas.microsoft.com/cdo/configuration/”
cdoFields.Item(schema & “sendusing”) = 2
cdoFields.Item(schema & “smtpserver”) = “smtp.gmail.com”
cdoFields.Item(schema & “smtpserverport”) = 465
cdoFields.Item(schema & “smtpauthenticate”) = 1
cdoFields.Item(schema & “sendusername”) = “gclshortt@gmail.com”
cdoFields.Item(schema & “sendpassword”) = “password”
cdoFields.Item(schema & “smtpusessl”) = 1
cdoFields.Update
With cdoMsg
    .To = “gshortt@domtech.net”
    .From = “gclshortt@gmail.com”
    .Subject = “Send email to gmail”
    ‘ Body of message can be any HTML code
    .HTMLBody = “Test message using CDO in vb6 to Gmail smtp”
    ‘ Add any attachments to the message
    .AddAttachment “c:\AccDo.ico”
    Set .Configuration = cdoConf
    ‘ Send the message
    .Send
End With
‘Check for errors and display message
If Err.Number = 0 Then
      MsgBox “Email Send Successfully”, , “Email”
Else
      MsgBox “Email Error” & Err.Number, , “Email”
End If
Set cdoMsg = Nothing
Set cdoConf = Nothing
Set cdoFields = Nothing
End Sub

Running the Program Send Email to SMTP Server

When you run the program you will get one of the following messages depending on if the email was correctly sent or not.

SMTP Email Send Successfully SMTP Email Error

Here is the message that arrives at the recipient:
Gmail Messaging

A simple mail transfer protocol is an easy way to share information from the PLC data collected.
You can download the following VB6 sample code here.

Watch on YouTube: How to Send Email to SMTP Server

If you have any questions or need further information please contact me.
Thank you,
Garry



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.