chore(doc/time):Update README
[EVA-2020-02.git] / doc / time / README.org
CommitLineData
6bdc2473
SBS
1* Time
2This document was created by Steven Baltakatei Sandoval on
3~2020-07-23T22:27Z~ under a [[https://creativecommons.org/licenses/by-sa/4.0/][Creative Commons BY-SA 4.0 license]]. It
4was updated by Steven Baltakatei Sandoval on ~2020-07-25T19:34Z~
5** Development Task list
6*** Set up prototype unit
aafe11cf
SBS
7**** DONE Solder wire for PPS signal
8***** 2020-07-25T20:03Z; bktei> Soldered pins to permit accessibility.
9 CLOSED: [2020-07-25 Sat 20:03]
6bdc2473
SBS
10**** Follow guide
11- [[https://ozzmaker.com/forums/topic/connecting-gps-pps-pin/][Ozzmaker post]] on ~PPS~ wiring and a [[https://www.satsignal.eu/ntp/Raspberry-Pi-NTP.html][guide]] recommendation.
12- [[http://www.satsignal.eu/raspberry-pi/Schmidt-RPZ-NTP-2016.pdf][Schmidt article]] on Raspberry Pi Zero time server.
13- [[https://gpsd.gitlab.io/gpsd/gpsd-time-service-howto.html][GPSD dev ref]] page for ~gpsd~ interfacing with ~ntp~.
aafe11cf 14- [[https://raspberryautomation.com/connect-multiple-ds18b20-temperature-sensors-to-a-raspberry-pi/][Raspberry Autom]] article on specifying custom GPIO pin.
6bdc2473
SBS
15*** Document prototype unit
16** Narrative
17The ~ninfacyzga-01~ device is equipped with an Ozzmaker BerryGPS-IMU
18module which provides time and location data to ~gpsd~. The time is
19provided by GPS satellites which themselves are [[https://science.nasa.gov/science-news/science-at-nasa/2002/08apr_atomicclock/][equipped]] with atomic
20clocks. This extremely accurate set of clocks are needed since a GPS
21receiver calculates its position in space using a General Relativity
22calculation that uses the small variations in the time stamps received
23from each satellite. This means that ~gpsd~ may be used to set the
24system clock without a need for an internet connection to a default
25Debian time server; ~ninfacyzga-01~ can be its own time server.
26** Description
27*** Hardware
28Ozzmaker BerryGPS-IMU, Version 3
29*** Software
30This guide describes steps that may be used to convert a Raspberry Pi
31into a time server using ~gpsd~.
32** Operating Procedures
33*** Initial Startup
34**** Install Raspbian 10 (Buster) onto a Raspberry Pi Zero W.
35**** Install Hardware
36See [[https://ozzmaker.com/forums/topic/connecting-gps-pps-pin/][this]] Ozzmaker forum topic about connecting the BerryGPS-IMU
37~T_PULSE~ pin to GPIO 18.
38
39Connect the ~T_PULSE~ connection on the BerryGPS-IMU-3 to GPIO pin 18
aafe11cf
SBS
40(ex: with solder and wire) in order to provide the PPS data signal
41generated by the BerryGPS-IMU to the Raspberry Pi. Processing of this
42data signal is handled by adding a line to ~/boot/config.txt~ in the
43next section ("Install Software").
6bdc2473
SBS
44
45**** Install Software
6bdc2473
SBS
46These instructions assume that ~gpsd~ has already been setup to
47provide NMEA sentences to ~gpspipe~ for location. See the ~README.org~
48in ~doc/location~ for details. Basically, ~gpsd~ needs to be told via
aafe11cf 49its ~/etc/default/gpsd~ configuration file of which ~/dev/ttyS0~ will
6bdc2473
SBS
50provide the raw GPS module data.
51
aafe11cf
SBS
52***** Install packages via ~apt~
53Run the following command to install the required packages.
54: $ sudo apt install usbmount eject gpsd gpsd-clients python-gps pps-tools ntp
55
56***** Modify ~/boot/config.txt~
57In order to tell the Raspberry Pi to expect PPS data on ~BCM 18~ (pin
58number 12; see [[https://pinout.xyz/][RaspPi pinout]]), add the following line to
59~/boot/config.txt~ as described on [[https://ozzmaker.com/forums/topic/problems-with-pps-on-a-pi0w-running-raspian-and-attached-to-a-berrygps-imuv3/][this Ozzmaker page]]:
60
61: dtoverlay=pps-gpio,gpiopin=18
62
63PPS data can be confirmed by running:
64
65#+BEGIN_EXAMPLE
66$ sudo su -
67# ppstest /dev/pps0
68trying PPS source "/dev/pps0"
69found PPS source "/dev/pps0"
70ok, found 1 source(s), now start fetching data...
71source 0 - assert 1595708074.003644641, sequence: 219 - clear 0.000000000, sequence: 0
72source 0 - assert 1595708075.003709620, sequence: 220 - clear 0.000000000, sequence: 0
73source 0 - assert 1595708076.003779580, sequence: 221 - clear 0.000000000, sequence: 0
74source 0 - assert 1595708077.003850580, sequence: 222 - clear 0.000000000, sequence: 0
75#+END_EXAMPLE
76
77***** Add udev rule
78As per [[https://www.slsmk.com/how-to-setup-a-gps-pps-ntp-time-server-on-raspberry-pi/][the slsmk.com]] guide, create symbolic links expected by ~ntp~
79pointing to the PPS device. This may be performed by creating the file:
80
81: /etc/udev/rules.d/09-pps.rules
82
83with the contents:
84
85#+BEGIN_EXAMPLE
86KERNEL=="ttyAMA0", SUBSYSTEM=="tty", DRIVER=="", OWNER=="root", GROUP=="tty", MODE=="0777", SYMLINK+="gps0"
87#+END_EXAMPLE
88
89***** Modify ~/etc/modules~
90For older versions of Raspberry Pi, it may be necessary to explicitly
91require the ~pps-gpio~ module to be loaded by making sure
92~/etc/modules~ contains the line:
93
94: pps-gpio
95
96According to [[https://www.raspberrypi.org/forums/viewtopic.php?p=757747#p757747][this]] post on 2015-05-13T09:14 by [[https://www.raspberrypi.org/forums/memberlist.php?mode=viewprofile&u=31454][ame]] on the Raspberry Pi
97forums,
98
99#+BEGIN_QUOTE
100rowlandski wrote:
101> Hi,
102>
103> I want the RPi to load/probe the w1-gpio module on boot.
104>
105> I have added:
106>
107> sudo modprobe w1-gpio
108>
109> To the etc/modules file, but on boot it is not loaded.
110> I have checked this by the lsmod command. If i then enter the above line manually and then check it's there loaded.
111>
112> What's wrong with my line on code in the modules file?
113>
114> Thanks
115
116You no longer need to load modules for some devices. It's handled by devicetree.
117
118Search for "devicetree" on the forum, or start here:
119https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=97314
120#+END_QUOTE
121
122As of 2020-07-25, using Raspbian Buster 10 with a BerryGPS-IMU v3,
123~/etc/modules~ did not need to be modified.
124
125***** Remove DHCP client hooks
126As per [[https://www.slsmk.com/how-to-setup-a-gps-pps-ntp-time-server-on-raspberry-pi/][this]] guide, "remove ntp DHCP hook (so that it doesn't override ntp settings)".
127
128This can be performed by running the following command (shown in
129script form for readability):
130
131#+BEGIN_EXAMPLE
132if [ -f "/etc/dhcp/dhclient-exit-hooks.d/ntp" ]; then
133 mv /etc/dhcp/dhclient-exit-hooks.d/ntp /etc/dhcp/dhclient-exit-hooks.d/xxxntp-orig;
134else
135 echo "NTP exit hook does not exist";
136fi;
137#+END_EXAMPLE
138
6bdc2473
SBS
139*** Normal Startup
140*** Normal Operation
141*** Normal Shutdown
142*** Unscheduled Shutdown
143
144