I have made a couple digital clocks with ESP32 microcontrollers and LED displays.
One is just a basic 7 segment digital clock to keep in the bedroom. Another one is one with a LED dot display that displays the current time and a weather forecast.
Oh.. in order to provide a weather forecast, I have an outdoor ESP32 that measures temperature, air pressure and humidity.
Anyways, those and other ESP32 projects I’ve built need a source of accurate time. Sure you can manually set an ESP32’s time, and it will remain accurate for a good amount of time, but I wanted clocks that number 1 set themselves, and number 2 do the daylight savings time change over automatically.
So fortunately there is an NTP library available for ESP32’s and all you need to do is have them use a network time server to get and maintain their time.
Well since I was going to be playing a lot with these clocks as I developed them, and you end up rebooting them many times an hour. I figured I’d run a local NTP time server on my home’s file server raspberry PI. That way, since that machine hardly ever reboots, it would not be banging on a network time server so much.
That works great, but I also got interested in having my own, non network dependent time standard to set my clocks from. Now you can get modules that use radio to get a signal from WWV, but that’s not too reliable. I have an analog, so-called atomic clock, hanging up in my living room and occasionally it fails to do the DST switch over without help.
Well another source of accurate time is GPS. I built a GPS module for one of my ham radios to use as a time standard, so I figured why not also use GPS for setting the clock on the R PI server?
Fortunately I’m not the first one to do this and there is a lot of support and instruction for setting up a gps module as a time source to make a stratum zero NTP server.
And that’s what I did, for about 10 dollars I bought a newer pre-made GPS module (Much smaller than the one I built) and attached it to an old R-PI 2B that I had no other use for.
And wow, with a little fussing, it is now sitting there as my stratum zero time server. Then I configured my home file server’s NTP server to sync to that, and/or one of NIST’s network time servers.
Now, my primary NTP server, the one all my devices talk to, is kind of fail safe. It uses GPS time from my new server, and also uses the NIST server’s time in it’s calculations if it is available. If my new server goes down (like when I’m playing with things), it seamlessly switches to just using the NIST server. If my Internet connection goes down, it just uses my new server. If both go down, well then for that period of time, the file server’s system clock will drift and my digital clocks may also then drift a bit.. but those are the breaks, once at least one server is back, time will sync up to reality again.
If you are interested in playing with making a GPS based NTP server yourself, here are a couple links I found helpful: link1 talks about setting up an NTP server with GPS time, link2 is a basic guide for just getting GPS working on an R-PI.