Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

COM110 - Send Mail


mkaker Aug 27, 2013 06:51 AM

Hi,

we use an CR800 to collect some data und now e would like to try to use an COM110 device with an dynamic IP Adress for sending the Data back to the processing office mail account.

We are looking for an example piece of code how to send an mail, how to trigger the send mail on specific time and / or specific alert?

Is there any example available?


Thanks and Best Regards


Ken Conner Aug 27, 2013 07:57 PM

Here is an example program that will send an email if the datalogger panel temperature exceeds a predetermined threshold. You may also want to add a timer that prevents emails from going out every minute while the threshold is exceeded.

Public Send As Boolean
Public PTemp, batt_volt, Temp_Threshold = 40
Public Outstat
Public EmailSent
Public TXEmailResult As String *50
Public LastFileName As String *50
Public TXMessage As String *200

'EmailSend parameters
Const TXServerAddr = "smtp.gmail.com:587" 'This is the address of the SMTP server you want to use to send the email
Const TXToAddr = "Recipient@email.com" ' This is email address you want to send a message to.
Const TXFromAddr = "Sender@email.com" 'This is the email address that the recipient will see in the 'From'
Const TXSubject = "Email From CR1000" 'This is the subject of the email you will be sending
Const TXAttach = "" 'This is the local name of any attachments you want to send
Const TXUserName = "Username" 'This is the user name for the email account you will be sending the email from
Const TXPassword = "Password" 'This is the password for the email account you will be senging the email from

'Define Data Tables
DataTable (Test,1,-1) 'This is a data table named test that will write 1000 records before it starts over writing data
DataInterval (0,15,Sec,10) 'This data interval means a new record will be created every 15 seconds
Minimum (1,batt_volt,FP2,0,False) 'This means that you will record the minimum battery voltage over the last 15 second period
Sample (1,PTemp,FP2) 'This means that you will record the panel temperature at the top of a 15 second interval
EndTable

'Main Program
BeginProg
Scan (1,Sec,0,0) 'This means the program will have a main scan sequence that occurs every 1 second
PanelTemp (PTemp,_60Hz) 'This tells the data logger to measure its internal temperature

If PTemp > Temp_Threshold Then Send = True 'If the current panel temperature exceeds the temperature threshold then set Send to true to trigger sending a message

Battery (batt_volt) 'This tells the data logger to measure the voltage of the power source it is connected to

'Enter any other measurements you want to make here.....

TXMessage = "This is an automated alarm from station #4094. The current temperature of " & PTemp & "has exceeded the threshold." 'Form up the message body.

CallTable Test 'This tells the data logger to call the table named 'Test' definded above
NextScan

SlowSequence 'The slow sequence separates these instructions from the main scan. The slow sequence cannot hold up the mail scan.
Scan (1,Min,3,0) 'This means the slow sequence will occure every minute
If Send Then 'If the variable send is equal to true then do the following.
EmailSent = EmailSend (TXServerAddr,TXToAddr,TXFromAddr,TXSubject,TXMessage,LastFileName,TXUserName,TXPassword,TXEmailResult) ' This instruction tells the data logger to send an email using all the information from above.
Send = False 'After the email sends, set Send back to false to prevent sending multiple messages
EndIf
NextScan

EndProg


mkaker Sep 1, 2013 04:03 PM

Dear Ken,

thanks for the example, but it doesn't work.

The COM110 is configured with your "Mobil Data Assistent" and i have double checked the COM110 Connections with these tool.

How can i debug the execution of the code on the logger to find out the problem?

Thanks and Best Regards


aps Sep 1, 2013 09:21 PM

Please refer to the manual called the CS-GSM/GPRS that is on the UK website or CD supplied with the order. From the information that are you able to validate the logger is negotiationing a valid PPP session, i.e. it is given an IP address.

If so then check details of the mail server you are sending the email through. Please also report what is stroed in the TXEmailresult variable after an attempted transmission.


mkaker Sep 2, 2013 06:56 AM

Dear Andrew

the Mobil Data Assistent diagnosis is able to display an IP and at an vodafone.de network access.

How can i report TXEmailresult?

Thanks and Best Regards


aps Sep 2, 2013 05:12 PM

You need to select the options in the MDA program for the datalogger to run its own IP stack (rather than the modem). Unless you let the datalogger runs its stack it will not be able to send emails.

Once you select that configuration you will not see and IP displayed in the MDA window, but you would need to check in the logger status table, if you have a second method of connecting to the datalogger.

* Last updated by: aps on 9/2/2013 @ 1:43 PM *

Log in or register to post/reply in the forum.