Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How do I request time stamp from NTP server using sim900 AT commands?

Status
Not open for further replies.

Sparked

Newbie level 3
Joined
Jan 25, 2012
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,306
Hi,
sorry if this is a bit of a noob question as I am new to digital communications.

I am currently building a data logger and am using a SIM900 chip to send e-mails containing data.
I would like this data to be timestamped but to keep it accurate I need to update my SIM900's RTC with a time stamp received from a NTP time server.

Unfortunately the AT+CLTS (get local timestamp) returns an error. I assume its just the network I am on.
As an alternative I need to send a UDP packet to an NTP time server, but I am completely lost on how this would be done.
Could anyone post a list of the required AT commands that I need to use to do this?

My best guess was to use:
AT+CSTT=apn,username,password //Start task and set APN, username, and password
AT+CGATT //Check if connected to the GPRS network
AT+CIICR //I think this command is used to bring up wireless connection with GPRS, or CSD?
AT+CIPSTART=UDP,"time.digibase.ca",123 //This command starts a UDP connection with the NTP server
AT+CIPSEND //Tell the SIM900 I want to send a message
(Type my packet here)
<sub> //sub command to end "CIPSEND"

and then I would assume/hope that the response from the server would be available at the SIM900's rxd/txd port

Am I way off here, because it is not working? :cry:
 

Hmmm is my question to vague?
 

i managed to set up a connection with ntp server using sim900 module, also I`m new to this kind of stuff, and because of this im sure there is better ( optimized, etc.. ) way :
at+cstt = "apn","apn user name", "apn pass" // you should get OK to this command
at+ciicr // OK
at+cifsr // ip adress
at+cipstart="UDP","Server ip","123" // also OK and CONNECT OK
after that you have to send valid NTP message so the server will respond to it :
my message is array of 48 unsigned char where the first one array[0] has the value 0x23, all others is zero. That is because it is signal to ntp server that this message is request from client and that it is using ntpv4
after creating array..
at+cipsend=sizeof(array) // response should be >
then you should send array to your module and module should respond with OK or SEND OK ( im not sure now witch one ) and after that u will receive response from server ( also 48B)
you will see in definition of ntp how this response looks and how it should be parsed ...
after that you close your connection and update time using at+cclk command...
dont forget to attach to gprs first (at+cgatt)...
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top