Comments (9)
I have modified ezTime with microsecond resolution, and linear interpolation of a set (32) of recent NTP sync events. It also gradually increases the sync interval until it's only checking every 8 hours. The result is accuracy better than 1ms and compensation for crystal drift. It's only tested on ESP32. If there's interest I could clean it up and document it and submit it for merging here. This is an example of the performance (I have a Stratum 0 NTP server on my LAN, but its good on pool.ntp.org too).
from eztime.
Yay, nice!
Yes please.
from eztime.
Hi there ! That's nice !
Your linear regression of NTP offset describes a constant drift of you ESP32. That's why you can increase delay between NTP sync. This is not true when you have some temperature variations for example if your crystal is not temperature compensated.
from eztime.
Naturally: keeping a constant eye on it is much better...
from eztime.
How did you mesure your overall accuracy @alwynallan ?
from eztime.
Thanks for encouragement. I'll have it cleaned up and submitted in a week.
Regarding accuracy, I've been using this approach in an ESP8266 application for years. There are statistical techniques to put confidence bands on the locus of the regression line, and reasonable to assume that the accuracy is the half-width of the band at the current time. In my current application the accuracy is limited by millisecond resolution of the time, but usually settles around 2ms as seen below. With microsecond resolution I'm sure it'll be better that 1ms. Below is a typical chart from my ESP8266 application.
Regarding quartz crystals they are very strange when studied closely over a long period of time. Identical parts can have positive and negative temperature coefficients, and they can have different natural modes that they stay in for weeks, and then suddenly change, with slightly different frequencies. The also change frequency slightly as they age. The consumer-grade parts are usually "binned" so they'll be within spec (say +-20ppm) but seldom in the middle of the range. I have some that slowly change frequency in a repeating sinusoidal pattern, but the period is 2.5 days, while the temperature variation has a 1-day period. Regression does a good job smoothing all this out and improving on both the crystals and NTP.
from eztime.
An idea about the source of the 2.5 days period ? I agree that temperature is around 1-day period if it's due to ambiant temperature. Is your MCU core load constant ?
What about supply voltage fluctuation ?
For our readers, here 2 interesting links about crystal drift for Arduino and ESP32 :
from eztime.
from eztime.
from eztime.
Related Issues (20)
- How to tell if NTP has been successfully update after manually setting time with setTime HOT 2
- FritzBox Router sends wrong ntp packet
- Library ignores if EERPROM is already being used
- Use SPIFFS for caching timezone? HOT 1
- Inspiration: Color Clock HOT 1
- hour() is off when passing in a timestamp, or I'm using it wrong? HOT 2
- can't set time zone for Asia/Tehran
- Improving library features
- Asia/Jerusalem returns empty posix string HOT 1
- readme update for "different languages"
- examples Timezones.ino proposed enhancement - thanks
- Dublin timezone incorrect time HOT 1
- 'myTZ was not declared in this scope'
- Feature request
- day(t) seems to return incorrect value
- Using ezTime with nodemcu-32s w/64x32 HUb75 LED Matrix HOT 5
- Stack problem whtn activate the waitForSync
- ezTime for ESP32 Wired Ethernet on Olimex ESP32-POE-ISO Working
- Won't sync with NTP if module can't access internet HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eztime.