To refresh the context of the problem: RTC in my PyBoard Lite is ~2.4% slower than it should be based on comparisons with PC clock. While it may not look much it, for example, gives 23 min error over the period of about 15 hours. Given that I plan to deploy current meter for a month it's clear why there has to be some way to compensate.
RTC.calibrate() method doesn't allow to compensate that much. Maximum it can do is to slow down or speed it RTC for ~0.0488%.
I assume that this RTC lag is consistent in it's speed so I can do following:
- Before logging setup RTC to match my PC clock and capture that as t0
- Deploy meter and let it do the logging
- Dismount logger for data download
- Before downloading logs and while PyBoard is still running, connect to it and capture PyBoard RTC value and my PC clock value as t_actual and t_expected correspondingly
- Based on difference between expected and actual timestamps and duration since logging started calculate "speed up coefficient"
- Apply that coefficient to timestamps in my logs before processing them further
Math is pretty simple here. Let's assume that our RTC speed is some fraction of real (well working clock) speed. Than if we sync them at moment t_0 we get this:
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
Hi there, I tried many RTCs of different manufacturers but I can only recommend one: the humble maxim DS3231. It is temperature compensated and has a few seconds of drift per year. Problem with all other RTCs is they're dependent on internal or external quartz/capacitors, which are very prone to temperature drift.
I guess your drift could change direction with temperatures and other factors. In your case it would mean an small additional PCB, but maybe it would be worth it in the long run? After all it's data you want to reliably time-stamp!
Edit: the cheap eBay modules use mostly old stock chips and not fake ones even if the price is lower than the bare "real thing" at Maxim semi. Got a batch of the 8 pin SO ones from an Chinese eBay vendor and checked the time/date code with Maxim, they're genuine as well.
Are you sure? yes | no
Thanks for the hint Jan! One of PyBoard founders also highly recommended DS3231 as very precise and affordable. I'm not really concerned about few seconds drift per year as underwater currents usually happen at a scale of minutes and tens of minutes. Also existing data on currents has one minute time-resolution.
I guess I'll go and buy that chip. Maybe from Adafuit? Do you know any other good source of parts for DYI tinkering except Aliexpress :) ?
Are you sure? yes | no
If you want the bare chip, I got my latest batch from lcsc.com. They're a huge reputable vendor (belong to JLC PCB I think) in china and only sell genuine stuff for prices much lower than digikey etc.
There is a good comparison for those cheap eBay boards here: https://blog.heypete.com/2018/02/04/ds3231-drift-results-5-months/
I guess buying a bunch of them while reading a few seller/product ratings should be safe.
Are you sure? yes | no