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.

Sending both SMS and email


schiller Jul 18, 2014 06:12 AM

Hello,

I´m using CR1000 and CS-GPRS with COM-110 modem.
When sensor values exceed critical thresholds I´d like to send a warning via SMS and email, but I couldn´t manage to send both.
Sending Alarm-SMS works fine, also Alarm-email, but i failed to implement both like in the test-program below:

Public Batt, RefTemp, Temp

Const CRLF = CHR(13)+CHR(10)
Const SMSPORT=ComSDC7
Const SMSPhone = """XXXXXXXXXXXXXXXXXXXXXX"""
Const CR=CHR(13)

Const ServerAddr="XXXXXXXXXXXXXXXXXXXXXX"
Const ToAddr="XXXXXXXXXXXXXXXXXXXXXX"
Const FromAddr="XXXXXXXXXXXXXXXXXXXXXX"
Const Subject="Email Message Test"
Const Attach=""
Const UserName="XXXXXXXXXXXXXXXXXXXXXX"
Const Password="XXXXXXXXXXXXXXXXXXXXXX"

Public SMSResult1
Public SMSSent1
Public AlarmTrigger As Boolean

Public Result As String * 50
Public Message As String * 250
Public EmailSuccess As Boolean

Sub SMS

Message = "Warning!" + CRLF + CRLF
Message = Message + "This is a automatic email message from the datalogger station " + Status.StationName + ". "
Message = Message + "An alarm condition has been identified. "
Message = Message + "The temperature is " + Temp + " degrees C." + CRLF + CRLF + CRLF
Message = Message + "Datalogger time is " + Status.Timestamp
EmailSuccess=EMailSend (ServerAddr,ToAddr,FromAddr,Subject,Message,Attach,UserName,Password,Result)

EndSub

Sub Mail

SerialOpen (SMSPORT,115200,3,10000,100)
SMSResult1=SerialOut (SMSPORT,"AT+CMGS="+SMSPhone+CR,"> ",5,100)
If SMSResult1<>0 Then
SerialOut (SMSPORT,"3018, km15,25, MURE Station01 - Datalogger time: " + Status.Timestamp + CRLF,"",1,10)
SMSResult1=SerialOut (SMSPORT,CHR(26),"CMGS:",1,1000)
SMSSent1=SMSResult1<>0
EndIf
SerialClose(SMSPORT)

EndSub

BeginProg
SMSSent1=True
Scan (1,Sec,3,0)
SW12(1)
Battery (Batt)
PanelTemp (RefTemp,250)
TCDiff (Temp,1,mV2_5C,1,TypeT,RefTemp,True ,0,250,1.0,0)
NextScan

SlowSequence
Scan(1,sec,1,0)
If AlarmTrigger = False Then
If Temp > 30 Then AlarmTrigger = True
If AlarmTrigger Then

'In Case of Alarm first send SMS
Call SMS

'then send email
Call Mail

EndIf
EndIf
If Temp < 30 then AlarmTrigger=False
NextScan
EndProg


smile Jul 18, 2014 06:34 AM

Hi,
I have not carefully analyzed your program and do not know if this is the issue. But quickly I can tell you that in order to send SMS, you must throw down the GPRS connection.

Smile


schiller Jul 18, 2014 07:34 AM

hello and thx for the fast reply!

can this possibly done by software and if so - how?
or do I have to switch off the SW12, power the modem down an wait until it has reinitiated?
I would prefer the first option, because as the near-real-time-sending of the alarm is of importance this would be a loss of valuable time, which i want to avoid.


smile Jul 18, 2014 10:16 AM

Hi,

in your program you can use the "TCPOpen/TCPClose" command, at regular intervals or in on the occasion of the need to send SMS alerts (consider a delay). You should, however, create the time period for the data connection in GSM-CSD, in case of problems with the GPRS. Even GSM calls, such as SMS, are not going to succeed if the GPRS connection is active.

Smile

* Last updated by: smile on 7/18/2014 @ 4:31 AM *


schiller Jul 22, 2014 11:02 AM

Hello,

so in case sending the Alarm-email has higher priority than the Alarm-SMS i can trigger the email-sending first, then throw down connection by using TCPClose, re-initiate connection with TCPOpen and finally send the SMS, is that the appropriate way?
Should a Delay be inserted before sending the SMS, and if so - how long?


smile Jul 23, 2014 06:47 AM

Hi Schiller,

I edit what you've written.

so in case sending the Alarm-email has higher priority than the Alarm-SMS i can trigger the email-sending first, then throw down connection by using TCPClose, send the SMS, then wait for confirmation of sending SMS correctly and finally re-initiate connection with TCPOpen.
Very probably that is the appropriate way.

I think that is enough to send SMS in the next scan, after that the GPRS connection is was closed.
Remember to enable the sending of SMS in the modem setup, with the command "AT + CMGF = 1". In text mode, to me it seemed so much easier.
Smile


schiller Jul 23, 2014 09:42 AM

Thank you for the reply - I´ll give it a try!


Curt_Ingram Jul 23, 2014 04:11 PM

Also be aware that mobile carriers usually have an email account associated with a mobile number. For example, AT&T subscribers can be sent a text to their phone by sending an email to

(10 digit phone number)@txt.att.net

1234567891@txt.att.net

There is a list available online that describes all of the carriers and the email to text format.

I have found this to be a much better solution for me as email seems to work without much fuss.

The list is here
http://www.emailtextmessages.com/

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