mediastore93
Posts: 12
Joined: Wed Nov 18, 2015 12:39 am

Will Pi keep time after removing internet connection?

Wed Aug 16, 2017 8:49 pm

I want to remove my usb wifi from my pi zero after the correct time is set, how long will the time remain reasonably correct if its not synching? 1 or 2 minutes either way after a couple of months is fine (presuming there are no reboots).

Thanks.

User avatar
DougieLawson
Posts: 38883
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Will Pi keep time after removing internet connection?

Wed Aug 16, 2017 9:06 pm

It'll be mostly ok untill you pull power and reboot. Then the clock restarts from shutdown time.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
rpdom
Posts: 17029
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Will Pi keep time after removing internet connection?

Wed Aug 16, 2017 9:22 pm

Or you could buy a cheap DS3231 RTC module with battery for it and with a bit of simple configuration it will keep a reasonably accurate time for you even when the Pi is switched off or rebooted.

It will require some GPIO pins to be soldered to the Pi Zero, but you don't need the full 40-pin connector, just pins 1, 3, 5 and 9.

User avatar
Burngate
Posts: 6290
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Will Pi keep time after removing internet connection?

Thu Aug 17, 2017 10:06 am

mediastore93 wrote:
Wed Aug 16, 2017 8:49 pm
... 1 or 2 minutes either way after a couple of months is fine ...
You're asking for ±1 in 50000 accuracy, or 20 ppm. That appears to be about what one might expect from a crystal oscillator.

AFAIK there's only one time-keeping device on-board - a crystal - and it's not been cut specifically for time-keeping. Nor is it kept at constant temperature.
So you may or may not be lucky with your particular Pi, in the particular environment in which you're using it.

It just so happens that there are 60 days in two months and 60 seconds in a minute, so you could set up an experiment.
See if it keeps time to within a second over a twenty four hour period

W. H. Heydt
Posts: 12431
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Will Pi keep time after removing internet connection?

Thu Aug 17, 2017 2:31 pm

rpdom wrote:
Wed Aug 16, 2017 9:22 pm
Or you could buy a cheap DS3231 RTC module with battery for it and with a bit of simple configuration it will keep a reasonably accurate time for you even when the Pi is switched off or rebooted.

It will require some GPIO pins to be soldered to the Pi Zero, but you don't need the full 40-pin connector, just pins 1, 3, 5 and 9.
Or, depending on the RTC, pins 1-8. For a 1, 3, 5, 7, 9 pin RTC, see this https://thepihut.com/products/mini-rtc- ... =758601217 one. For the pin 1-8 (with replaceable battery!), see this one: http://www.mcmelectronics.com/product/83-17980

A couple of notes. First, the one from Pi Hut uses a supercap, rather than a battery. It will only hold the time for between two and three days without power, so you need to think about the conditions under which it will be in use. On the one I have running, the time is within 2 to 3 seconds after a bit more than 100 days, indicating that it should be within 10 seconds per year. As for the one from MCM, the install instructions are not complete. I set one up (following those instructions) and the Pi didn't see it. Due to other constraints, the last week was very busy with non-Pi stuff, so I have yet to get back to figure out why (I have my suspicions). On the other hand, who knows, perhaps Stretch will work with it as per the those instructions.

In general, the Pi will only read the RTC to set the system clock on boot. If you want to correct the time from the RTC periodically, you'll need to schedule an RTC read operation from time to time.

Martin Frezman
Posts: 1009
Joined: Mon Oct 31, 2016 10:05 am

Re: Will Pi keep time after removing internet connection?

Thu Aug 17, 2017 2:54 pm

This thread really has nothing to do with RTC, so that's mostly a distraction.

Although using an RTC may (emphasis "may") be an end-around solution to OP's underlying problem, via the hack of periodically (via cron) reading the RTC's time into the system time. However, my very limited experience (playing around with one particular RTC on the Pi) is that the RTC's time isn't much better (in fact, seemed to be worse) than the (onboard) system timekeeping.
If this post appears in the wrong forums category, my apologies.

W. H. Heydt
Posts: 12431
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Will Pi keep time after removing internet connection?

Fri Aug 18, 2017 12:00 am

Martin Frezman wrote:
Thu Aug 17, 2017 2:54 pm
This thread really has nothing to do with RTC, so that's mostly a distraction.

Although using an RTC may (emphasis "may") be an end-around solution to OP's underlying problem, via the hack of periodically (via cron) reading the RTC's time into the system time. However, my very limited experience (playing around with one particular RTC on the Pi) is that the RTC's time isn't much better (in fact, seemed to be worse) than the (onboard) system timekeeping.
Any RTC is going to be worse than an Pi with access to NTP servers. However, the OP wants to run without a network connection and, hence, without NTP service. The following is for a Pi0 with a network connection. The RTC hasn't been written to since it was set up, so the comparison here is RTC to NTP and a free running system clock is very unlikely to be better than the RTC:

Code: Select all

pi@pi0ntp:~ $ uptime; date; sudo hwclock -r
 16:57:26 up 102 days, 19:20,  3 users,  load average: 0.06, 0.06, 0.01
Thu Aug 17 16:57:26 PDT 2017
Thu 17 Aug 2017 04:57:27 PM PDT  -0.198464 seconds
pi@pi0ntp:~ $

User avatar
rpdom
Posts: 17029
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Will Pi keep time after removing internet connection?

Fri Aug 18, 2017 6:31 am

Martin Frezman wrote:
Thu Aug 17, 2017 2:54 pm
However, my very limited experience (playing around with one particular RTC on the Pi) is that the RTC's time isn't much better (in fact, seemed to be worse) than the (onboard) system timekeeping.
Depends which RTCs you use. In my not so limited experience the one I mentioned has internal temperature compensation, which improves the accuracy considerably.

User avatar
DougieLawson
Posts: 38883
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Will Pi keep time after removing internet connection?

Fri Aug 18, 2017 1:44 pm

rpdom wrote:
Fri Aug 18, 2017 6:31 am
Martin Frezman wrote:
Thu Aug 17, 2017 2:54 pm
However, my very limited experience (playing around with one particular RTC on the Pi) is that the RTC's time isn't much better (in fact, seemed to be worse) than the (onboard) system timekeeping.
Depends which RTCs you use. In my not so limited experience the one I mentioned has internal temperature compensation, which improves the accuracy considerably.
It doesn't really matter, the underlying reason for using an RTC is not accuracy. The reason for an RTC is that the clock keeps running when the Raspberry is powered off, so the system powers back on with something close to the right time of day.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

W. H. Heydt
Posts: 12431
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Will Pi keep time after removing internet connection?

Fri Aug 18, 2017 2:27 pm

DougieLawson wrote:
Fri Aug 18, 2017 1:44 pm
It doesn't really matter, the underlying reason for using an RTC is not accuracy. The reason for an RTC is that the clock keeps running when the Raspberry is powered off, so the system powers back on with something close to the right time of day.
I wouldn't say that as an absolute. Indeed, the OPs question (about clock accuracy without access to NTP servers) is a case in point where an accurate RTC could be used to periodically correct the system clock.

Martin Frezman
Posts: 1009
Joined: Mon Oct 31, 2016 10:05 am

Re: Will Pi keep time after removing internet connection?

Fri Aug 18, 2017 3:36 pm

I wouldn't say that as an absolute. Indeed, the OPs question (about clock accuracy without access to NTP servers) is a case in point where an accurate RTC could be used to periodically correct the system clock.
Precisely.

As usual, Dougie doesn't read; he just posts.
If this post appears in the wrong forums category, my apologies.

mediastore93
Posts: 12
Joined: Wed Nov 18, 2015 12:39 am

Re: Will Pi keep time after removing internet connection?

Thu Aug 24, 2017 12:53 am

Thank you for all your replies, very helpful.

Return to “Beginners”