Pages: [1]   Go Down
Author Topic: Using AT commands to get time from NTP server?  (Read 5664 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 36
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

Does anyone know how to send a request to a NTP server using AT commands with a SIM900?
I am using the iComSat GSM shield and have a simple sketch that allows me to send AT commands to the SIM900 using a terminal program.
My goal is to have the NTP server send my arduino a time-stamp that will allow me to update my RTC. Before I even attempt to write any code that has the arduino do this task automatically I would like to be able to do it myself using a terminal program and AT commands.
If anybody knows of any good resources/tutorials that may help would you be kind enough to post a link?

Just from looking at a few NTP time libraries (that work with an Ethernet shield) I realize that I need to send a data packet, but I am unsure of what AT command will let me do this.
Any help is much appreciated.



 
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 224
Posts: 13915
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Does anyone know how to send a request to a NTP server using AT commands with a SIM900?

I didn't know that it can be done at all with AT commands. Do you have a link to the datasheet of the SIM900.

If it is possible the datasheet should describe how to send an UDP packet over the internet. The content of such packet can be reverse engineered from several time libs.
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 36
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is a link to the SIM900 AT Command set: http://robokits.co.in/datasheets/SIM900_ATC_V1_00.pdf

and her is a link to an application note for the SIM900: http://www.svtehs.com/simcom/docs/SIM900_AN_TCPIP_V100.pdf

I just assumed that this was possible as the SIM900 has an AT Command AT+CLTS that is supposed to get a local timestamp; however it states that this command is network dependant and unfortunately it doesn't seem to work on the Rogers network.


Also I should let you know that there is a command to start a UDP connection (AT+CIPSTART=) that I can use to connect to a NTP server port 123.  I have successfully made this connection.  I would think that after that I would just use AT+CIPSEND to send a data packet.  I guess what I don't know how to do is create the packet.
« Last Edit: January 23, 2012, 03:42:05 pm by Sparked » Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 224
Posts: 13915
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


par. 3.1.2 gives an example of how to make an UDP connection...
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 36
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hmmm ok,
So I managed to establish a UDP connection to an NTP time server.
I just don't know what to send to the server.  I have a feeling I'm going to be reading about packets and packet formats all night!
I am guessing after the connection is established I am basically sending a string of 1's and 0's?  Does that sound about right?
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 224
Posts: 13915
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I am guessing after the connection is established I am basically sending a string of 1's and 0's?  Does that sound about right?
No, you should send binary data aka bytes.

In the page below a simple NTP sketch is presented, you can see what bytes to send and what to expect back (also binary data)

- http://arduino.cc/playground/Main/DS1307OfTheLogshieldByMeansOfNTP -
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

with sim900 you can update time from the cellular network automatically at startup ,

follow these steps,
Code:
AT+CLTS=1\r
AT+CENG=3\r

after this on every attachment with network you will get
Code:
*PSUTTZ: 2013, 2, 23, 8, 22, 51, "+16", 1

DST: 1

*PSUTTZ: 2013, 2, 23, 8, 22, 54, "+16", 0

DST: 0

and the local time stamp will be updated to local time
check by command
Code:
AT+CCLK?
Logged

Pages: [1]   Go Up
Jump to: