Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Found a strange delay that occurs every half hour #69

Closed
Bewear opened this issue Mar 18, 2017 · 3 comments
Closed

Found a strange delay that occurs every half hour #69

Bewear opened this issue Mar 18, 2017 · 3 comments

Comments

@Bewear
Copy link

Bewear commented Mar 18, 2017

I'm using TimeLib.h and TimeAlarms.h for a clock with alarms, the sync is made through NTP server once everyday and I noticed that every 30 minutes now() loses one second (I'm not using now() but hour(), minute() and second()). I've tested my clock for 7 hours, the time at the beginning was the same my smartphone had and after those 7 hours Arduino lost 14 seconds. Is that a power issue? I'm using the USB port, an LCD screen, 3 buttons, a buzzer, a PIR and WiFI Shield.

@Bewear Bewear changed the title Found a strange delay Found a strange delay that occurs every half hour Mar 18, 2017
@gsexton
Copy link

gsexton commented Mar 18, 2017

This is just the inaccuracy of the resonator on the Arduino. You need to either adjust for drift, or sync more frequently. You could also consider using a DS3231 Clock chip. You could use NTP to periodically set the DS3231, and read it. To adjust for drift, use NTP to sync the clock. 24 or so hours later, look at system elapsed time, and the NTP elapsed time. Calculated an offset and then any time you're reading the local clock, multiple the offset by the time since last sync via NTP.

I'm in the process of building a WWVB radio-controlled clock. Looking at my unit (an Inland UNO R3), I lose 55.145 seconds per day, for a drift rate of -6.40e-4. Your drift rate is pretty similar.

@Bewear
Copy link
Author

Bewear commented Mar 18, 2017

I have a RTC bit I'm already using all of the pins (WiFi Shield takes 7 pins for communication and the Uno only got 12 pins). Probably I'll resync every 30 minutes or even 10 minutes, or use a Mega.

@Bewear
Copy link
Author

Bewear commented Mar 18, 2017

But wait, I'll get a drift even with an external clock?

@Bewear Bewear closed this as completed Mar 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants