Hi there,
I’m setting up my first weather station due to a university project and since it won’t always have reliable internet available (it’s gonna be at the top of a mountain in Italy with 2G at best) I’m gonna use a Glonass GPS U-blox 7 to get the NMEA time signal and keep the clock aligned.
The reasoning behind this is that satellites have 3 atomic clock each inside them (Stratum 0) and can be used as reference clocks to avoid having time to drift.
The computer will connect to them and will use them to become Stratum 1 and keep the time in sync without drifting.
Of course we had the choice to pick the Linux distro and I picked my beloved Fedora (it might become RHEL 8 in the future if we see any stability issue).
Anyway, I installed gpsd and gpsd-clients and make it start at boot time with:
I even checked the gpsd configuration in /etc/sysconfig and set it to:
# Options for gpsd, including serial devices
START_DAEMON=”true”
USBAUTO="true"
DEVICES="/dev/ttyACM0″
GPSD_OPTIONS="-n"
and I also changed chronyd in /etc/ accordingly to make use of it:
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
pool 2.fedora.pool.ntp.org iburst
pool pool.ntp.org iburst
server time1.google.com
server time2.google.com
server time3.google.com
server time4.google.com
#Connect to GPS Atomic Clock
refclock SHM 0 offset 0.5 delay 0.2 refid NMEA
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3
# Enable kernel synchronization of the real-time clock (RTC).
# Enable hardware timestamping on all interfaces that support it.
hwtimestamp *
# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2
# Allow NTP client access from local network.
#allow 192.168.0.0/16
# Serve time even if not synchronized to a time source.
#local stratum 10
# Specify file containing keys for NTP authentication.
keyfile /etc/chrony.keys
# Get TAI-UTC offset and leap seconds from the system tz database.
leapsectz right/UTC
# Specify directory for log files.
logdir /var/log/chrony
# Select which information is logged.
#log measurements statistics tracking
when I check the satellites with xgps I can see satellites and with gpsd I can see the data, however chronyd doesn’t seem to like NMEA and it’s saying #? as if it’s not a source, in fact there’s no data from it.
Why?
Because you delay it, it won’t be seleted over other internet-sources.
You can even poll it more often, like 2 instead of 4, you may get better time setting it at 2.
but I’m still getting the same error, I mean the source is marked as #? (i.e unreachable).
By the way, for reference, this is a continuation of this thread here: Setting up Chrony and NMEA for time clock
Yes, I tried rebooting and nothing, still #?
I even tried not using xgps and cgps -s, but it didn’t change anything.
Speaking of which, if I can’t use xgps and cgps -s, how do I know that the GPS has actually got the timestamp? I mean, sure, I can see the green light blinking instead of a fixed red one, but can’t I use something through Fedora to actually check?
Happy New Year for you too, @FranceBB, and welcome to the community!
There seems to be some syntax error in the gpsd configuration file in /etc/sysconfig directory. (May be cut&paste issue from the documentation?) Please check that the double quotes are having the normal ASCII 042 octal code values, and not the fancy back double quotes with the higher values from UNICODE page.
Try running ntpshmmon from gpsd to confirm there are some measurements written to the memory segment. Then I’d suggest to stop the system chronyd service and run chronyd -d -d in terminal to get the debug output. There should be an error message if chronyd is receiving the measurements, but ignoring for some reason.
Thanks for the additional tips.
Unfortunately the university is temporarily closed during the holidays, so I can’t test 'till Monday next week. I noticed the non ASCII quote and replaced them with real ASCII quotes “”, namely "" so hopefully it should work now.
About the speed of the Ublox, I didn’t actually set it anywhere, so I guess it’s defaulting it to something?
Anyway, I’ll test with the changes on Monday.
Although I brought the ublox home with me (so it’s not at university and I could technically test it), my apartment block faces south, therefore it won’t be able to get a fix, which is why I gotta test it at university where I have the actually mini pc that will be deployed to the weather station and a south facing room from which the ublox can get the 2D and 3D fix.
I’ll let you know and… see you on Monday, I guess!
The GPS is very accurate and spot on.
So much so that even now that I’m testing at university and I have an internet connection, it still goes for Stratum 0 as it’s more accurate, thus proving that it works correctly!
BTW, stratum 0 or stratum 4 are not more or less accurate, the time is passed from one to another.
The accuracy is the same.
It just means that your closer to the Atom-clock that is feeding your system with time.
In fact, your if your GPS is the only time-source, it means your server can be less accurate then getting time from multiple sources, as e.g. clouds, snow, reflections can make a GPS go jump on accuracy.
Therefor you need more sources to ensure your timeserver is as accurate as possible.
A GPS with PPS has less problems with this, but without PPS will jump a bit more.
When weather conditions go real bad, it can happen that your GPS won’t be selected as primary source, doesn’t happen often but I have seen it doing that.
Marco you are right when talking about 20 years back.
But then most NTP-servers depended on phone-calls and other stuff en depend a lot on the system-oscillator. (internal clock)
Today there is no problem to connect to multiple sources and correct every few seconds.
Also we have hardware time-stamping so corrections can be made.
The difference between Stratum 0, 1, 2, 3 etc won’t be that large to notice much of a difference.
Sure, when using 1 source alone can be a problem, but no one should do that these days.
Just look:
Stratum : 1
Ref time (UTC) : Wed Jan 11 18:29:01 2023
System time : 0.000001498 seconds fast of NTP time
Last offset : +0.000000740 seconds
RMS offset : 0.000004086 seconds
Frequency : 11.423 ppm fast
Residual freq : +0.018 ppm
Skew : 1.420 ppm
Root delay : 0.000000001 seconds
Root dispersion : 0.000004641 seconds
Update interval : 1.0 seconds
Leap status : Normal
Stratum : 2
Ref time (UTC) : Wed Jan 11 18:48:47 2023
System time : 0.000000000 seconds fast of NTP time
Last offset : -0.000001436 seconds
RMS offset : 0.000237727 seconds
Frequency : 12.194 ppm fast
Residual freq : +0.030 ppm
Skew : 1.226 ppm
Root delay : 0.016264930 seconds
Root dispersion : 0.000411160 seconds
Update interval : 16.1 seconds
Leap status : Normal