I realize that the standard advice, for good reason, is to use a
computer with a battery-backed RTC.  However, for those not doing that,
there is an alternative, which is to wait for NTP to be happily synced.
I have tested this somewhat, and am unsure if there is a window when NTP
syncs and realizes it is far off and then adjusts, so perhaps the "are
things ok" logic should be better.  But I send my script anyway in case
it helps someone, or someone can point out why this is confused.

On booting a RPI3 with the wifi wedged (not a weewx issue) and leaving
it for hours, and then making the network work, I had log lines that
looked like:

  UNSYNC 127.0.0.1: stratum 16, offset 0.000000, synch distance 0.000000
  UNSYNC 127.0.0.1: stratum 16, offset 0.000000, synch distance 0.000000
  UNSYNC 127.0.0.1: stratum 16, offset 0.000000, synch distance 0.000000
  UNSYNC 127.0.0.1: stratum 16, offset 0.000000, synch distance 0.000000
  UNSYNC 127.0.0.1: stratum 16, offset 0.000000, synch distance 0.000000
  UNSYNC 127.0.0.1: stratum 16, offset 0.000000, synch distance 0.000000
  OK 127.0.0.1: stratum 3, offset -0.002891, synch distance 0.042083
  Thu Apr 18 15:55:19 EDT 2019
  associd=0 status=0618 leap_none, sync_ntp, 1 event, no_sys_peer,
  system peer:        173.0.156.209:123
  system peer mode:   client
  leap indicator:     00
  stratum:            3
  log2 precision:     -19
  root delay:         84.166
  root dispersion:    998.679
  reference ID:       173.0.156.209
  reference time:     e06354a6.4182be99  Thu, Apr 18 2019 15:55:18.255
  system jitter:      8.636792
  clock jitter:       0.965
  clock wander:       0.000
  broadcast delay:    -50.000
  symm. auth. delay:  0.000
       remote           refid      st t when poll reach   delay   offset  jitter
  ==============================================================================
   [redacted addrs             ]    3 s    -   64   17   23.996   -1.688   5.556
   [                           ]    2 u    1   64   11   95.937    1.922   0.592
  -[                           ]    2 u    7   64   17  224.692  -10.475   1.508
   [                           ]    2 u    1   64   17   84.169    0.769   0.497
  +[                           ]    2 u    6   64   17   50.154   -2.841   1.415
  *[                           ]    2 s    3   64   17   26.173   -1.535   1.971
   [                           ]    3 s    -   64   17    6.780    0.245   0.657
  +[                           ]    3 s    9   64   17   27.120    2.948   1.018



In this case the time was very close because the system had just done a
quick reboot, so it was only 45s slow or something like that.


The script:
----------------------------------------
#!/bin/sh

date
ntpq -c sysinfo
ntpq -pn

while sleep 5; do
    trace=`ntptrace -n | head -1`
    stratum=`echo $trace | sed -e 's/.*stratum \([0-9]*\),.*/\1/'`
    if [ "$stratum" -lt 16 ]; then
        echo OK $trace
        break;
    fi
    echo UNSYNC $trace
done

date
ntpq -c sysinfo
ntpq -pn

bin/weewxd weewx.conf

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to