Black Lives Matter - Action and Equality. ... Adafruit is part of the Stop Hate for Profit campaign. Adafruit is open and shipping.
0

Raspberry Pi GPS Stratum 1 NTP Server
Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Please be positive and constructive with your questions and comments.

Re: Raspberry Pi GPS Stratum 1 NTP Server

by Tobi2707 on Sat Mar 28, 2015 1:15 pm

You should add 'noselect' to the Pool Server and then restart ntp.
Then regard ntpq -pn again

If this doesn't help gtj may has a better advice

Tobi2707
 
Posts: 87
Joined: Thu Mar 12, 2015 8:07 am

Re: Raspberry Pi GPS Stratum 1 NTP Server

by stan_qaz on Sat Mar 28, 2015 1:56 pm

gtj - Great, the PPS mystery solved! Thanks.

Tobi2707 - Adding noselect to the server might not do what I want which is to provide some source of external time if the GPS has issues. I'll keep that in mind as an option if I keep dropping the GPS as the selected server. At some point I want to swap out the pool server for the one offered by my ISP but I don't want to make non-generic changes until all is working well.


I still have quite a bit of reading to do, not only to understand all the steps that I more or less blindly followed here but to also figure out just what to do about setting up my local time service system. Tentatively I'm hoping the Pi will supply time from GPS or as a fallback my ISP's ntp service.

For now I plan to only connect to the Pi from two local systems, an OpenSuse server that handles file storage and other network services and a pfSense firewall that provides DHCP. I currently have the two configured as NTP sources for my client systems, either in DHCP or manually for clients that don't accept the DHCP option so adding the Pi into the server and firewall ntpd.conf files in addition to the other servers there now should be a simple process.

With about 50 LAN clients here I don't think the NTP load is going to be high enough to impact the Pi so once everything is working well for a couple months I think switching all my local systems over to use the Pi directly and as the preferred server will be the best arrangement while keeping the OpenSuse and pfSense systems as potential fallbacks.

stan_qaz
 
Posts: 46
Joined: Sat Mar 21, 2015 7:44 pm

Re: Raspberry Pi GPS Stratum 1 NTP Server

by gtj on Sat Mar 28, 2015 4:41 pm

If you're still having problems, re-summarize them and I'll take a look.

The Pi won't even notice 50 clients. :)

gtj
 
Posts: 109
Joined: Wed Feb 04, 2015 9:11 pm

Re: Raspberry Pi GPS Stratum 1 NTP Server

by Tobi2707 on Mon Mar 30, 2015 2:50 am

I now have another questions:
With the Pi using as stand-alone ( no LAN/internet connected), how can i get the ntp output?
ntpq -pn doesn't work without LAN and till now i used "ntpq -pn 127.0.0.1" is there a better solution?

With no LAN connected i get a Offset of 20ms, which is slowly decreasing but really much slower than with the LAN plugged in. Is this normal?

And last question: My time is now 1 hour off (daylight saving time) how can i change this?

Tobi2707
 
Posts: 87
Joined: Thu Mar 12, 2015 8:07 am

Re: Raspberry Pi GPS Stratum 1 NTP Server

by gtj on Mon Mar 30, 2015 12:52 pm

Tobi2707 wrote:I now have another questions:
With the Pi using as stand-alone ( no LAN/internet connected), how can i get the ntp output?
ntpq -pn doesn't work without LAN and till now i used "ntpq -pn 127.0.0.1" is there a better solution?

You could create an alias so ntpq always uses 127.0.0.1...
Code: Select all | TOGGLE FULL SIZE
$ echo alias ntpq=\'ntpq -c \"host 127.0.0.1\"\' >> ~/.bashrc

Now whenever you type 'ntpq' you'll automatically be connected to 127.0.0.1.

Tobi2707 wrote:With no LAN connected i get a Offset of 20ms, which is slowly decreasing but really much slower than with the LAN plugged in. Is this normal?

The Pi doesn't have a battery backed up clock and without a network connection, it can't get the initial time so ntpd is going to take a little extra time to synchronize. I'm not sure there's anything that can be done about this but I'll investigate a little.

Tobi2707 wrote:And last question: My time is now 1 hour off (daylight saving time) how can i change this?

Try running raspi-config and make sure that time timezone is correct. It's under Internationalisation Options.

gtj
 
Posts: 109
Joined: Wed Feb 04, 2015 9:11 pm

Re: Raspberry Pi GPS Stratum 1 NTP Server

by gtj on Mon Mar 30, 2015 1:04 pm

I just ordered a few of the ChronoDots. I'm going to mount them on the prototype part of the GPS hat and wire them to the I2C bus. That should give the the Pi a nice RTC for stand-alone operation. I'll post an update when I've tried it out.

gtj
 
Posts: 109
Joined: Wed Feb 04, 2015 9:11 pm

Re: Raspberry Pi GPS Stratum 1 NTP Server

by Tobi2707 on Mon Mar 30, 2015 3:28 pm

The time zone is correct...
So I will take a look what is wrong...

Did You get my email?

Do you have any monitoring the ntp accuracy? On satsignal.eu there is something with mrtg but it's to hard for me. IS there a way to get acces to the offset field and e.g. Let a led glow when the accuracy is +- 10us?

Tobi2707
 
Posts: 87
Joined: Thu Mar 12, 2015 8:07 am

Re: Raspberry Pi GPS Stratum 1 NTP Server

by stan_qaz on Mon Mar 30, 2015 3:37 pm

So far all is well here, my NTP error rates are drifting ever closer to zero and I have had no further glitches or problems.

On getting a decent time to set the Pi's clock to until NTP is available and stable I had thought using the internal clock in the module would be an option. So far I have spent my morning pouring over the datasheets and what documentation is available but haven't found a way to do that. I sent a query to the module manufacturer and am awaiting a reply.

http://www.gtop-tech.com/en/product/PA6 ... le_04.html

stan_qaz
 
Posts: 46
Joined: Sat Mar 21, 2015 7:44 pm

Re: Raspberry Pi GPS Stratum 1 NTP Server

by gtj on Mon Mar 30, 2015 4:03 pm

Tobi2707 wrote:The time zone is correct...
So I will take a look what is wrong...

Did You get my email?

Do you have any monitoring the ntp accuracy? On satsignal.eu there is something with mrtg but it's to hard for me. IS there a way to get acces to the offset field and e.g. Let a led glow when the accuracy is +- 10us?


I'm a little behind on email, sorry.

The offset can be found in the /var/log/ntpstats/loopstats file. It's the third column. There were instructions a while back on how to turn on the stats.
'tail -1 /var/log/ntpstats/loopstats' will always get you the last line in the file.

You could try writing a short script that reads that last line periodically and turns on or off the Pi's LEDS.

My Pi 2 has 2 leds, a green and a red. They are available in /sys/class/leds/led0 and /sys/class/leds/led1 respectively. To control them...


Code: Select all | TOGGLE FULL SIZE
## Take control of the led manually
$ echo none > /sys/class/leds/led0/trigger
## Turn it on
$ echo 255 > /sys/class/leds/led0/brightness
## Turn it off
$ echo 0 > /sys/class/leds/led0/brightness

gtj
 
Posts: 109
Joined: Wed Feb 04, 2015 9:11 pm

Re: Raspberry Pi GPS Stratum 1 NTP Server

by gtj on Mon Mar 30, 2015 4:09 pm

stan_qaz wrote:So far all is well here, my NTP error rates are drifting ever closer to zero and I have had no further glitches or problems.

On getting a decent time to set the Pi's clock to until NTP is available and stable I had thought using the internal clock in the module would be an option. So far I have spent my morning pouring over the datasheets and what documentation is available but haven't found a way to do that. I sent a query to the module manufacturer and am awaiting a reply.

http://www.gtop-tech.com/en/product/PA6 ... le_04.html


First, that's good news.

Actually, I could whip up a quick 'gpsdate' command that works like ntpdate except it gets it's date from the GPS. That's a good catch. I can work on it this afternoon. It'll probably be while before you hear from Global Top. :)

gtj
 
Posts: 109
Joined: Wed Feb 04, 2015 9:11 pm

Re: Raspberry Pi GPS Stratum 1 NTP Server

by Tobi2707 on Tue Mar 31, 2015 2:46 am

I don't have this file: /var/log/ntpstats/loopstats

Since yesterday I have a new problem:

When i reboot the Pi the Offsets goes from 0,6 to 3,4 ms (takes ~4 minutes), then it gets the 'o' and decreases to 0,3 ms (takes 1 minute) after this it increases from 0,3 to 16,4 ms (takes 1 minutes) and after this all it decreases very slowly to 0,001ms (takes 1 hour). Could this depend on changing the timezone or that the weather is cloudy?

Conspicuously the Offset from the pool server which is 'no select' is extremely high 3455999ms oO

Code: Select all | TOGGLE FULL SIZE
pi@raspberrypi ~ $ ntpq -pn
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
o127.127.20.0    .GPS0.           1 l    2    8  377    0.000   -4.483   0.393
 178.63.135.195  36.224.68.195    2 u   17   64  377   53.823  3455999   5.798


And the timezone:
Code: Select all | TOGGLE FULL SIZE
pi@raspberrypi ~ $ date
Fr 27. Mär 07:26:30 CET 2015


But it should be Fr 27.Mär 08:26:30 CEST 2015..

Tobi2707
 
Posts: 87
Joined: Thu Mar 12, 2015 8:07 am

Re: Raspberry Pi GPS Stratum 1 NTP Server

by gtj on Tue Mar 31, 2015 11:34 am

For the statistics, make sure the following lines aren't commented out in ntp.conf...

Code: Select all | TOGGLE FULL SIZE
# Enable this if you want statistics to be logged.
statsdir /var/log/ntpstats/

statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable


It's hard to tell about the initial drifting. I forget, are you using the external antenna and is the antenna outside? Neither the kernel nor ntpd pay any attention to timezone. That's only used by applications to display a local time. The huge offset with the pool server is puzzling though. It's almost an hour which is suspicious.

Exactly which timezone did you pick? Maybe the definition isn't correctly defining the start of DST.

gtj
 
Posts: 109
Joined: Wed Feb 04, 2015 9:11 pm

Re: Raspberry Pi GPS Stratum 1 NTP Server

by stan_qaz on Tue Mar 31, 2015 11:43 am

I'm surprised but I had an e-mail waiting for me this morning, apparently there is no command to query the internal GPS backup clock from the outside.

Hello Stanley,

First of all, thank you for your interesting in our module. The RTC just for improve module TTFF that can not be used a system's internal clock, if you have any further questions please don't hesitate to let us know.

Best regards
Brian (Chinese name blocked by the spam filters here on the forums)

Subject Products Inquiry
Inquiry Items http://www.gtop-tech.com/en/product/PA6 ... le_04.html

I have read your documentation but can not find a method to query the on chip real time clock so I can use it to set my system's internal clock when GPS signals are not present.

Do you have any information on doing this or suggestions on where I should be looking for this information?

stan_qaz
 
Posts: 46
Joined: Sat Mar 21, 2015 7:44 pm

Re: Raspberry Pi GPS Stratum 1 NTP Server

by gtj on Tue Mar 31, 2015 11:55 am

Well, at least you got a timely response!

I added a 'set_system_clock' command to the gpsinit program in my utils project... https://github.com/f5eng/mt3339-utils

You can then add the following to your /etc/rc.local file...
Code: Select all | TOGGLE FULL SIZE
service ntp stop
/usr/local/bin/gpsinit -s 115200 -i set_system_clock /dev/ttyAMA0
service ntp start


At least if the gps has a fix, you'll get a pretty good starting time.

gtj
 
Posts: 109
Joined: Wed Feb 04, 2015 9:11 pm

Re: Raspberry Pi GPS Stratum 1 NTP Server

by Tobi2707 on Tue Mar 31, 2015 12:18 pm

gtj wrote:It's hard to tell about the initial drifting. I forget, are you using the external antenna and is the antenna outside? Neither the kernel nor ntpd pay any attention to timezone. That's only used by applications to display a local time. The huge offset with the pool server is puzzling though. It's almost an hour which is suspicious.

Exactly which timezone did you pick? Maybe the definition isn't correctly defining the start of DST.


I'm using the external antenna, but indoors directly on the window. I did pick Europe -> Berlin ( i live in Germany) which should be UTC+2...

Tobi2707
 
Posts: 87
Joined: Thu Mar 12, 2015 8:07 am

Please be positive and constructive with your questions and comments.