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.

email sending issue


masdarmech Oct 20, 2010 08:06 PM

i am trying to send an e-mail through the CR1000 datalogger. i am using easy GPRS to connect to the internet. i am using GPRS command to acquire the IP address. then i am trying to use "emailsend" command to send an e-mail to a hotmail account from a gmail account. i have enabled TSL encryption on my device. however, the email result gives me "failed to connect" my crbasic code is:

Public PTemp, batt_volt,i,j,ipstrlength
Public EmailResult As String
Public ip_adress As String * 50
Public str_out As String
Public str_in As String
Public ip_address As String * 50
Public EmailSuccess As Boolean

'Define Data Tables
DataTable (Test,1,1000)
DataInterval (0,15,Sec,10)
Minimum (1,batt_volt,FP2,0,False)
Sample (1,PTemp,FP2)
EndTable

'Main Program
BeginProg
i=1
j=1
Scan (15,Sec,0,0)
' PanelTemp (PTemp,250)
' Battery (Batt_volt)
SerialOpen(ComRS232,9600,0,10,450)
SerialFlush(ComRS232)

SerialOut(ComRS232,"AT"+CHR(13)+CHR(10),0,0,100)'to check if modem is on
SerialIn(str_in,ComRS232,500,"K",30)
Delay(1,1,Sec)
SerialFlush(ComRS232)
If i=1
SerialOut(ComRS232,"at#sgact=1,1"+CHR(13)+CHR(10),0,1,100)'acquire IP address
SerialIn(ip_adress,ComRS232,500,"O",300)
i=0
ipstrlength=Len(ip_adress)
ip_address=Right(ip_adress,ipstrlength-9)
ip_address=Trim(Left(ip_address,Len(ip_address)-2)) 'get ip address from the string #SGACT: xx.xxx.xx.xx
SetStatus("IPgateway",ip_address)
SetStatus("pppIPAddr",ip_address)

ElseIf i=2
SerialOut(ComRS232,"at#sgact=1,0"+CHR(13)+CHR(10),0,1,100)'to close connection
SerialIn(str_in,ComRS232,500,"K",30)
i=0
EndIf

'ip_adress=PPPOpen()
' Delay(1,1,Sec)
IPRoute(ip_address,0)
EmailSuccess=EMailSend("smtp.gmail.com","address@hotmail.com","address@gmail.com","hi","hi","","username@gmail.com","password",EmailResult)
'While j<>3
' EmailSuccess=EMailSend("smtp.gmail.com","address@hotmail.com","address@gmail.com","hi","hi","","username@gmail.com","password",EmailResult)
'j=j+1
'Wend
'Delay(1,1,Sec)
'PPPClose()
'Enter other measurement instructions
'Call Output Tables
'Example:
CallTable Test
NextScan
EndProg

can you kindly guide me how to send e-mail to an account using SMTP after my modem is connected to the internet and have got an IP address from the ISP.

* Last updated by: masdarmech on 10/20/2010 @ 2:08 PM *


Dana Oct 20, 2010 09:48 PM

A good troubleshooting tool (if you are using at least CR1000 OS 20), is to monitor the IPtrace information via a serial port.

Using DevConfig (Settings Editor tab) or PakBus Graph (right-click the datalogger and choose Edit Settings), find the IPTrace Code field. Enter a code of 4 (see the DevConfig help for this field to see all of the available codes). Set the IP Trace Com port field to RS232 and save the settings.

Connect a cable between the datalogger's RS232 port and the computer. Set up Hyperterminal to connect with the datalogger on that COM port; e.g., set the bits per second to whatever the RS232 port baud rate is, 8 data bits, No parity, 1 stop bit, no flow control.

Connect to the datalogger with Hyperterminal, then trigger your emailsend. You should be able to see the traffic on the datalogger's IP port, and you may be able to see where the emailsend process is breaking down.

Regards,

Dana W.


masdarmech Oct 20, 2010 11:35 PM

i am using datalogger's rs-232 port to interact with modem. however i am connecting my PC to datalogger cs 1/o port using sc105.

i didn't see any traffic on windows hyper terminal (i don't know why) however i tried the IPtrace command to see the IP error notifications. it was saying:

cannot find smtp host: smtp.mail.yahoo.com
;ppp ip=0.0.0.0

(i switched from gmail or hotmail to yahoo as they require TLS authentication and i don't know if this e-mail send command supports it or not)

apparently my assigning of IP by using "setstatus" command isn't working as i checked through station status. can you kindly guide me how to do this using "emailsend" function of cr1000.

i tried to send e-mail through easy GPRS commands or simple SMTP commands
and i was able to send e-mails using a serial terminal software.

thanks,
Tauha


aps Oct 21, 2010 12:41 PM

The emailsend function will only work if you have a TCP/IP connection the datalogger recognises as active. It has to establish the PPP connection to do so and will then gets its own IP address etc. The basic details are described in this manual, although some detials may be different for your modem.

ftp://ftp.campbellsci.com/pub/csl/outgoing/uk/manuals/cs_gprs.pdf

In recent operating systems we also support TLS - this is enabled in the settings screen of the logger, accessed via the Device configuration program.


masdarmech Oct 21, 2010 04:43 PM

i tried to use simple "ATD*99***1#" as the modem dial string
and modem response string as "CONNECT" but with this i never get an IP address. i exactly don't know what does the PPPopen command do.

what i guess is, it is just a modem dial string after which the modem should do all the authentications and pull out the IP address from the network. in my case, i know my modem has a built-in TCP/IP stack (as also present in the previous modem MC-35i) but i never get any IP after issuing the "PPPopen()" command. this was the reason i ordered easy GPRS telit modems so that i don't have to worry about all that.

Can you kindly guide me how to tell the datalogger that my modem is already connected to the internet with the specified IP. i get it from issuing AT#SGACT=1,1 command and then doing some string manipulation to have a string variable in "xxx.xxx.xxx.xxx" format.


masdarmech Oct 21, 2010 06:22 PM

i can provide you with the hyper terminal output when i use the PPPopen() command as told by Dana. in summary it says "No DNS entries" then some messages which i wasn't able to understand.


aps Oct 21, 2010 09:14 PM

If you put entries in the setup for PPP and set an active PPP port the logger will automatically try to establish a PPP connection.

Your expectation of what the modem/logger does is not correct. The ATD*99***1# command (note you do not need the ATD) tells the modem to dial and initiate the PPP connection. The datalogger then does all the negotiation and establish the connection using the standard binary PPP protocol which involves it getting an IP address. It uses its own TCP/IP stack and does not rely on anything in the modem. Emailsend will not work unless you work this way.

Can I refer you back to the CS-GPRS manual making sure you have set the APN settings in the modem too.


masdarmech Oct 21, 2010 10:14 PM

thanks for responding. i entered the dial string as only *99***1# but still the response is "no DNS entries". i also tried using dial string AT+CGDCONT=1,"IP";AT+CGATT=1;ATD*99***1# but still the same response. my ISP don't need any username or password. i tried the same lines on my serial communication software and got the CONNECT word. i also updated my OS from 19 to 20 but still the problem remains there. Kindly find the CRBASIC code for the testing purpose:
'CR1000 Series Datalogger
'To create a different opening program template, type in new
'instructions and select Template | Save as Default Template
'date:
'program author:

'Declare Public Variables
'Example:
Public PTemp, batt_volt,i,j,ipstrlength, ip_error As String * 80
Public EmailResult As String
Public ip_adress As String * 50
Public str_out As String
Public str_in As String
Public ip_address As String * 50
Public EmailSuccess As Boolean

'Define Data Tables
DataTable (Test,1,1000)
DataInterval (0,40,Sec,10)
Minimum (1,batt_volt,FP2,0,False)
Sample (1,PTemp,FP2)
EndTable


'Main Program
BeginProg

Scan (20,Sec,0,0)
ip_adress=PPPOpen()
Delay(0,5,Sec)
EmailSuccess=EMailSend("smtp.mail.yahoo.com","xxx@xxx.com","xxxx@yahoo.com","hi","hi","","xxxx@yahoo.com","xxxx",EmailResult)
Delay(0,5,Sec)
' PPPclose()
CallTable Test
NextScan
EndProg

can you kindly tell me how can i access the CR1000 memory and write my own code using easy GPRS commands (basically serial commands) to send e-mail (by bringing data table in form of a string) with a file attachment or through FTP.


aps Oct 25, 2010 04:57 PM

You need to enter an APN server name as the third parameter to the AT+CGDCONT parameter otherwise the logger will not be able to setup the GPRS connection. (The modem needs to have that setting whether you use the logger TCP/IP stack or not)

You cannot access anything at a lower level to be able to send emails with the emailsend command.

All you can do if you want to try to use the modems own stack is send out a series of AT commands, which should allow you to send basic messages. We do not offer support on that mode of operation.


Sigma Dubai Apr 14, 2013 02:36 PM

Hi Masdarmech,
I am also in UAE and wanted to contact you about advise on EmailSend, can i have your email ID?

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