NTP
Whilst it is easy to get a fairly decent NTP clock reference - I wondered about building my own.
Parts
- Orange Pi
- OrangePi One
- GPS Chip
- NEO6
- 4 Jumper Leads M/F
Build OS
After several attempts to configure the OragePi - the OS is the probem not the hardware. I used armbian in the end. No matter whoch OS you choose you will have to do these steps.
- Build OS - Change Machine Name - Set Static IP Address - Setup UART access - Test NMEA Output - Install GPSD - Install NTP
That sounds like a lot of stuff - but the most difficult is Setup UART Access. I could not accomplish this on Ubuntu. Hence I switched to Armbian (which was the 1st time I had used the OS - but it seems very well done - and easy to use).
All OS installs were command line only - No GUI !!
So with the OS setup... I moved onto the GPS chip.
GPS Chip
Pinout for the Orange Pi
GPS Chip Pins
The GPS chip has 4 connections, but as we do not send data to the GPS chip.. I did not connect the RX (on GPS) pin.
GPS Name | Wire Color | PI Pin Connection | PI Pin Name |
---|---|---|---|
VCC | Red | 1 | VCC-3V |
RX | Yellow | 8 | Not connected |
TX | Orange | 10 | UART3_RX |
GND | Green | 6 | GND |
OS Software
With the GPS Wires to the OrangePi, I then rebooted - checled the voltage with a Multi-Meter - looked ok. And then tried to understand why I could not see any data.
The problem is that I am using UART3 pin conections - so I need to enable UART3 in the boot config process.
Warning: This is OS specific I could not find a way to accomplish this using Ubuntu, so I switched to armbian - with a little tweaking I was then able to enable uart3 (armbian-config -> System -> Hardware).
Verify you have data
cat /dev/ttyS3
And I see NMEA Sentances.
$GPGSV,3,2,12,12,08,213,30,13,79,012,28,15,57,255,24,20,33,040,24*74 $GPGSV,3,3,12,24,15,192,17,25,00,244,25,29,34,303,18,30,17,063,31*71 $GPGLL,1509.56255,N,12041.76433,E,031417.00,A,A*66 $GPRMC,031418.00,A,1509.56262,N,12041.76423,E,0.344,,190922,,,A*77 $GPVTG,,T,,M,0.344,N,0.638,K,A*2D $GPGGA,031418.00,1509.56262,N,12041.76423,E,1,10,0.92,31.2,M,36.9,M,,*6F $GPGSA,A,3,06,29,15,05,12,30,20,02,13,11,,,1.65,0.92,1.37*00 $GPGSV,3,1,12,02,57,353,17,05,39,351,24,06,25,118,21,11,51,090,34*75 $GPGSV,3,2,12,12,08,213,30,13,79,012,28,15,57,255,25,20,33,040,24*75 $GPGSV,3,3,12,24,15,192,17,25,00,244,25,29,34,303,18,30,17,063,30*70 $GPGLL,1509.56262,N,12041.76423,E,031418.00,A,A*6C
GPSD Setup
There really is no point in installing gpsd until you can see the NMEA data. That is the #1 priority.
sudo apt install gpsd gpsd-clients
Then
vi /etc/default/gpsd
This is what mine looks like
DEVICES="/dev/ttyS3" START_DAEMON="true" # Other options you want to pass to gpsd GPSD_OPTIONS="-n" # Automatically hot add/remove USB GPS devices via gpsdctl USBAUTO="false"
Now enable the gpsd service and check it is running
systemctl enable gpsd.service #This adds the service systemctl start gpsd.service #Manually start systemctl status gpsd.service #check it is running
The service should auto start .. so we can reboot to check that
sync && reboot -h now
Viewing the GPS Data
There are two useful utilities
- cgps -s -u m.
- gpsmon
These are command line (as there is no screen) on this device.
Lack of PPS
The Gps module I bought was a NEO-6, it only has 4 wires connecting it... and there is no PPS (pulse per second) feature.
I am therefore unsure if this will add accuracy to my NTP process.
NTP
Installed with
apt-get install ntp
As I only have a GPS feed and not a PPS as well - I can only add 1 source
Place these lines in /etc/ntp.conf
# gpsd clock via shm server 127.127.28.0 minpoll 4 maxpoll 4 prefer fudge 127.127.28.0 refid GPS flag1 1
And restart ntp
systemctl restart ntp.service
To see if our GPS feed is being used (xSHM) [accessed via shared memory].
ntpq -p
remote refid st t when poll reach delay offset jitter ============================================================================== xSHM(0) .GPS. 0 l - 16 377 0.000 -7.059 2.269 0.ubuntu.pool.n .POOL. 16 p - 64 0 0.000 +0.000 0.001 1.ubuntu.pool.n .POOL. 16 p - 64 0 0.000 +0.000 0.001 2.ubuntu.pool.n .POOL. 16 p - 64 0 0.000 +0.000 0.001 3.ubuntu.pool.n .POOL. 16 p - 64 0 0.000 +0.000 0.001
The important figure to look at is the Jitter... the GPS source is quite low.... which means it should be having a good effect on the time source.
Next Steps
- More Accuracy. -Either get another gps with PPS - this could be added to the same OrangePi, so there are two sources.
- Use the NTP Internally
- On my main development servers I have pointed them to use bigben