Setting up the Raspberry Pi to support and use the GPS module is a pretty straight forward job.

When Gunnar first did this, he followed the instructions from another site where the GPS module was used to set up a Stratum 1 NTP server. You can find that site here: http://ntpi.openchaos.org/pps_pi/

 

The short version of this setup is as follows.

Edit /boot/cmdline.txt andremove console=ttyAMA0,115200 from the line.

This will disable the factory terminal console set up on the GPIO serial port.

Then and add bcm2708.pps_gpio_pin=18 to enable the Raspberry Pi to receive PPS signal on pin 18.

This is used by the NTP server to be able to synchronize time with very high accuracy.

The result should look something like this:

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait bcm2708.pps_gpio_pin=18

To completely remove the terminal console, edit /etc/inittab and remove the following line:

T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

And to complete the PPS GPIO setup, edit /etc/modules and add the following line:

pps-gpio

Now complete the GPS setup by installing all necessary tools and configure the GPSd daemon:

apt-get install pps-tools gpsd gpsd-clients
dpkg-reconfigure gpsd

 

The following configuration was used for our setup:

  • Start gpsd automatically
  • Set device to /dev/ttyAMA0
  • Add option “-n” (to force GPSd to keep polling the GPS even if no clients are connected)

 

Setting up the GPS as source for a local NTP server

Edit /etc/dhcp/dhclient.conf and remove ntp-servers from the request line. The result should look something like this:

request subnet-mask, broadcast-address, time-offset, routers,
 domain-name, domain-name-servers, domain-search, host-name,
 dhcp6.name-servers, dhcp6.domain-search,
 netbios-name-servers, netbios-scope, interface-mtu,
 rfc3442-classless-static-routes;

Then remove /var/lib/ntp/ntp.conf.dhcp if present.

Now edit /etc/ntp.conf and make it look like this:

# pps-gpio on /dev/pps0
server 127.127.22.0 minpoll 4 maxpoll 4
fudge 127.127.22.0 refid PPS
fudge 127.127.22.0 flag3 1 # enable kernel PLL/FLL clock discipline

# gpsd shared memory clock
server 127.127.28.0 minpoll 4 maxpoll 4 prefer # PPS requires at least one preferred peer
fudge 127.127.28.0 refid GPS
fudge 127.127.28.0 time1 +0.130 # coarse processing delay offset

server 0.pool.ntp.org iburst
server 1.pool.ntp.org iburst
server 2.pool.ntp.org iburst
server 3.pool.ntp.org iburst

Reboot the system and when it is back up again you can check if you are using the GPS as NTP source by executing:

ntptrace

If the output states that you are a stratum 1 server, you have succeeded.

localhost: stratum 1, offset 0.000000, synch distance 0.000000, refid 'GPS'

 

Setting up Message Distribution System

To distribute positions and other useful events from the vehicle tracker to the central server, a AMQP system called RabbitMQ is used.

To install this on a Raspberry Pi, add the RabbitMQ debian repository to apt.

Do this by creating a new file /etc/apt/sources.list.d/rabbitmq.list and add the following line:

deb http://www.rabbitmq.com/debian/ testing main

The run the following commands to trust the new repository you added:

wget http://www.rabbitmq.com/rabbitmq-signing-key-public.asc
sudo apt-key add rabbitmq-signing-key-public.asc

Now you can install RabbitMQ by running the following commands:

apt-get update
apt-get install rabbitmq-server

To get the GUI management for RabbitMQ, the plugin rabbitmq_management need to be installed.

And for our setup, we will be using the shovel plugin to send messages from the vehicle tracker to the central server.

Install these plugins by running the command:

rabbitmq-plugins enable rabbitmq_management rabbitmq_shovel rabbitmq_shovel_management

Now set up a user account you want to use when connecting to the management and give it the administrator tag.

Replace “admin admin” with the username and password you would like to use:

rabbitmqctl add_user admin admin
rabbitmqctl set_user_tags admin administrator

 

Sources:

http://ntpi.openchaos.org/pps_pi/

http://www.satsignal.eu/ntp/Raspberry-Pi-NTP.html

http://search.cpan.org/dist/Net-GPSD3/lib/Net/GPSD3/Return/TPV.pm