NTP support
NTP support
Postby Tomer » Thu Dec 25, 2014 4:40 pm
Hi All,
I added two new AT commands to get the time from NTP servers (pool.ntp.org). I used AT commands version 20 as starting point.
AT+CIPNTP=<offset from GMT> , to initialize the ntp, and start syncing the time - for example: AT+CIPNTP=2 to intialize it with GMT+2 offset.
AT+CIPNTP? - to get the current time, for example:
AT+CIPNTP?
Time: 22:22:42 12/02/2014 GMT+02
Binaries compiled with SDK 0.9.3: http://bit.ly/esp8266-ntp
Binaries compiled with SDK 0.9.4: http://bit.ly/esp8266-ntp0-9-4
Source code with SDK 0.9.3: https://github.com/TomerCo/ESP8266-AT
Comments/Suggestions are welcome.
I added two new AT commands to get the time from NTP servers (pool.ntp.org). I used AT commands version 20 as starting point.
AT+CIPNTP=<offset from GMT> , to initialize the ntp, and start syncing the time - for example: AT+CIPNTP=2 to intialize it with GMT+2 offset.
AT+CIPNTP? - to get the current time, for example:
AT+CIPNTP?
Time: 22:22:42 12/02/2014 GMT+02
Binaries compiled with SDK 0.9.3: http://bit.ly/esp8266-ntp
Binaries compiled with SDK 0.9.4: http://bit.ly/esp8266-ntp0-9-4
Source code with SDK 0.9.3: https://github.com/TomerCo/ESP8266-AT
Comments/Suggestions are welcome.
Re: NTP support
Postby scargill » Thu Dec 25, 2014 7:17 pm
HI
On the assumption that the files load at 0 and x040000 I have loaded the version compiled with SDK 0.9.4 - the AT command set responds - and I put in the information for my router.
I set it up - to my router.. and then issued the command to go get the time..
OK
AT+CWMODE=1
OK
AT+CWJAP="loft-east","xxxxxxxxx"
OK
AT+CIPNTP=0
Sntp initializing TZ: GMT00...
Sntp initializing...
pool.ntp.orgsntp_request: Waiting for server address to be resolved.
AT+CIPNTP=0
Sntp initializing TZ: GMT00...
Sntp initializing...
sntp_dns_found: Failed to resolve server address resolved, trying next server
sntp_retry: Next request will be sent in 3000 ms
pool.ntp.orgsntp_request: Waiting for server address to be resolved.
sntp_dns_found: Failed to resolve server address resolved, trying next server
sntp_retry: Next request will be sent in 6000 ms
pool.ntp.orgsntp_request: Waiting for server address to be resolved.
sntp_dns_found: Failed to resolve server address resolved, trying next server
sntp_retry: Next request will be sent in 12000 ms
pool.ntp.orgsntp_request: Waiting for server address to be resolved.
sntp_dns_found: Failed to resolve server address resolved, trying next server
sntp_retry: Next request will be sent in 24000 ms
pool.ntp.orgsntp_request: Waiting for server address to be resolved.
sntp_dns_found: Failed to resolve server address resolved, trying next server
sntp_retry: Next request will be sent in 24000 ms
pool.ntp.orgsntp_request: Waiting for server address to be resolved.
sntp_dns_found: Failed to resolve server address resolved, trying next server
sntp_retry: Next request will be sent in 24000 ms
pool.ntp.orgsntp_request: Waiting for server address to be resolved.
sntp_dns_found: Failed to resolve server address resolved, trying next server
sntp_retry: Next request will be sent in 24000 ms
I left this one for ages and it wimply would not resolve the address...
So I powered the unit off - and then on - and tried again - and it worked... have you tried the NTP command without having the IP address in intially and setting the router info just maybe 10 seconds or so before trying this command?
When it is finished getting the time could you please have the response end with a line "OK" or "ERROR" to make it easier to know if this has succeeded or not - indeed that's all we really need to know....
Does it try one NTP server (dangerous) or a pool?
Pete.
On the assumption that the files load at 0 and x040000 I have loaded the version compiled with SDK 0.9.4 - the AT command set responds - and I put in the information for my router.
I set it up - to my router.. and then issued the command to go get the time..
OK
AT+CWMODE=1
OK
AT+CWJAP="loft-east","xxxxxxxxx"
OK
AT+CIPNTP=0
Sntp initializing TZ: GMT00...
Sntp initializing...
pool.ntp.orgsntp_request: Waiting for server address to be resolved.
AT+CIPNTP=0
Sntp initializing TZ: GMT00...
Sntp initializing...
sntp_dns_found: Failed to resolve server address resolved, trying next server
sntp_retry: Next request will be sent in 3000 ms
pool.ntp.orgsntp_request: Waiting for server address to be resolved.
sntp_dns_found: Failed to resolve server address resolved, trying next server
sntp_retry: Next request will be sent in 6000 ms
pool.ntp.orgsntp_request: Waiting for server address to be resolved.
sntp_dns_found: Failed to resolve server address resolved, trying next server
sntp_retry: Next request will be sent in 12000 ms
pool.ntp.orgsntp_request: Waiting for server address to be resolved.
sntp_dns_found: Failed to resolve server address resolved, trying next server
sntp_retry: Next request will be sent in 24000 ms
pool.ntp.orgsntp_request: Waiting for server address to be resolved.
sntp_dns_found: Failed to resolve server address resolved, trying next server
sntp_retry: Next request will be sent in 24000 ms
pool.ntp.orgsntp_request: Waiting for server address to be resolved.
sntp_dns_found: Failed to resolve server address resolved, trying next server
sntp_retry: Next request will be sent in 24000 ms
pool.ntp.orgsntp_request: Waiting for server address to be resolved.
sntp_dns_found: Failed to resolve server address resolved, trying next server
sntp_retry: Next request will be sent in 24000 ms
I left this one for ages and it wimply would not resolve the address...
So I powered the unit off - and then on - and tried again - and it worked... have you tried the NTP command without having the IP address in intially and setting the router info just maybe 10 seconds or so before trying this command?
When it is finished getting the time could you please have the response end with a line "OK" or "ERROR" to make it easier to know if this has succeeded or not - indeed that's all we really need to know....
Does it try one NTP server (dangerous) or a pool?
Pete.
Last edited by scargill on Thu Dec 25, 2014 7:30 pm, edited 1 time in total.
-
- Posts: 1
- Joined: Fri Apr 29, 2016 8:14 pm
Re: NTP support
Postby anlpereira » Mon Feb 26, 2018 4:14 am
Hi, I'm using the new commands to get the time but the answer is Thu Jan 01 00:00:00 1970
Commands:
AT+CIPSNTPCFG=1,-3
OK
AT+CIPSNTPTIME?
+CIPSNTPTIME:Thu Jan 01 00:00:00 1970
Commands:
AT+CIPSNTPCFG=1,-3
OK
AT+CIPSNTPTIME?
+CIPSNTPTIME:Thu Jan 01 00:00:00 1970
Re: NTP support
Postby Her Mary » Wed Feb 28, 2018 1:15 pm
Code: Select all
+CIPSNTPTIME:Thu Jan 01 00:00:00 1970
It is the initial time, did you connect the ESP8266 to the router?
The SNTP time should be got from the internet, it needs to connect to the router first.
Who is online
Users browsing this forum: No registered users and 1 guest
Login
Newbies Start Here
Are you new to ESP8266?
Unsure what to do?
Dunno where to start?
Start right here!
Latest SDK
Documentation
Complete listing of the official ESP8266 related documentation release by ESPRESSIF!
Must read here!
- All times are UTC+08:00
- Top
- Delete all board cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. We are the manufacturer of ESP8266EX.