Close

No GPS module yet

A project log for ESP GPS NTP Server

A simple NTP server using GPS

liebmanliebman 11/04/2017 at 02:410 Comments

   While I don't have a GPS module, I do have boards from SynchroClock that have the DS3231 real time clock 1hz routed to a GPIO pin on on the ESP8266. This lets me pretend I have a GPS (and I read the current time from the DS3231).

  I used a strategy mentioned by @Nick Sayer, in the comments on one of his projects here, and used the ESP8266 builtin CPU cycle counter, 80Mhz, to interpolate the time between seconds.  And it answers queries!

flugelberry$ ntpdate -q -u 192.168.0.29
server 192.168.0.29, stratum 1, offset 0.273729, delay 0.06538
 3 Nov 19:39:51 ntpdate[8704]: adjust time server 192.168.0.29 offset 0.273729 sec

EDIT: It turns out that ESP.getCycleCount() is not very consistent.  Using this I end up with up with well over 250us of jitter!  Maybe something with idle sleep or some other power saving mode?  In any case using micros() works much much better with jitter less than 20us!

Discussions