6

How accurate would the time on my Raspberry Pi 3 be if it is continuously connected to the Internet, but without an RTC?

  • I don't now a precise answer, but it's a lot better than a second. How acurate do you need? – Christian Feb 20 '18 at 20:04
  • About 1 second accuracy would be good enough. – ON5MF Jurgen Feb 20 '18 at 20:21
  • 6
    The RTC isn't used for timekeeping when the system is up. It's one hwclock read on boot and one hwclock write on shutdown. When the system is up, HPET or other CPU timers are used, they are much more precise. – Janka Feb 21 '18 at 0:42
12

According to wikipedia, the Network Time Protocol used by default on Raspbian and millions of other networked devices and computers:

is intended to synchronize all participating computers to within a few milliseconds

In fact, NTP is used on systems (servers, PCs, etc.) that have an RTC in order to correct for the drift computer clocks may have. Meaning, if you added an RTC, it would be kept accurate by using the exact same network mechanisms that are used to set the OS "software" clock already (which, realistically, is tied to the processor frequency, i.e., there's crystal in there somewhere that effectively keeps the time while the system is on).

| improve this answer | |
13

Because the NTP protocol attempts to measure and compensate for network latency and other delays, it is very accurate even when using public time servers.

RTC is used to maintain system time when power is removed, and it not necessarily even accurate, after your raspberry PI has booted up and received the time from NTP it will continue to count time without an RTC even if network is disconnected.

When using NTP you are not continuously synchronizing to the network, the system time is maintained with a timer based on the cpu clock.


When run with a local network time server, NTP can achieve accuracy of <1ms.

When run over the public internet, dynamic and potentially asymmetric routing of packets contributes to a poorer estimate of network delays. However, you can expect accuracy of well under 1s with most documentation claiming an accuracy of 100ms over the public internet.

If you need better synchronization, without better accuracy, you may consider running a local NTP server to synchronize multiple raspberry pi relative to each other with better than 1ms synchronization (good for aligning sensor data) .

If you need both accuracy and synchronization, you can run a Stratum 1 NTP server using GPS as the time source.

| improve this answer | |
  • 1
    In fact, on a good internet connection the error is usually in the single-digit milliseconds. Those specs are from when computers and network connections were both quite a bit slower. – hobbs Feb 21 '18 at 1:29
8

Presence or absence of RTC has nothing to do with timekeeping precision. It's purely a matter of being able to keep (a poor approximation of) current time while the device is powered down so that the system time is correct before you bring up the network device and ntpd.

Note that if you want a secure remote clock source rather than plain ntp, you'll need to know a rough idea of the current time (accurate within month scale) in order to validate certificates; this is probably the main modern purpose of an RTC on internet-connected devices.

| improve this answer | |
3

Having done experiments with C++ on my RPI3 (Stretch) using the sys/time.h function gettimeofday(**) and the wiringPi API then measuring against a scope, streamlined applications can obtain sub-millisecond resolution and accuracy on timing.

Now if you are using other languages on the RPI you may not be able to obtain those speeds.

| improve this answer | |
2

We get accuracy of better than a second on several units using a public NTP server the other side of a complex and busy network. We also only need accuracy of the order of 1s (which the system clock can maintain for days while powered up).

Check out the ntpd man page, but after configuring a server, making sure that ntpd -g runs on boot should be all you need. The -g gets you back to real time if the clock is way out, such as after loss of power.

| improve this answer | |
  • chrony performs much better than ntpd on systems that might have their connection come and go at any time. – hobbs Feb 21 '18 at 1:30
  • @hobbs that's interesting. Better in what way? Mine are wired because of an issue with password storage and the connection is reliable. In fact they're more likely to lose power than network, but slowdowns sometimes happen. – Chris H Feb 21 '18 at 6:55
  • 2
  • In addition to the "unreliable network" operation, chrony can make a larger correction to the system clock frequency. If the difference between nominal clock frequency and observed clock frequency is more than ±500 parts per million, ntpd will not correct it. Basically, chrony works better in a virtual machine than ntpd. – Chad Farmer Mar 2 '18 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.