GPS server

GPS server (for info about integrating to OpenPlotter)

The Pi accept the GPS dongle via the USB port. The software gpsd provide the functions needed. It is easy to install, with Ubuntu which is commonly used on the PI the commands are simle (as root): "apt-get install gpsd gpsd-clients". To set up the gpsd service some updates to setup file are normally needed. The file  /lib/systemd/system/gpsd.service contains :

[Unit]

Description=GPS (Global Positioning System) Daemon

Requires=gpsd.socket

[Service]

EnvironmentFile=-/etc/default/gpsd

ExecStart=/usr/sbin/gpsd -N $GPSD_OPTIONS /dev/ttyACM0

[Install]

Also=gpsd.socket

In addition the file gpsd.socket (same directory) need to listen for requests on the host ip address, not just the localhost  (there is no place like 127.0.0.1). 

[Unit]

Description=GPS (Global Positioning System) Daemon Sockets

[Socket]

ListenStream=/var/run/gpsd.sock

#ListenStream=[::1]:2947

#ListenStream=127.0.0.1:2947

ListenStream=192.168.1.160:2947

SocketMode=0600

[Install]

WantedBy=sockets.target

The USB-GPS device is hardcoded into this file, but the device file might be different, /dev/ttyACM0 is common, but connect the GPS and check for the device using the command:  ls /dev/tty*. The ttyACM0, ttyUSB0 or ttyAMA0, if things fail check here for help.

To test the GPS server issue the command xgps <Pi server IP addreress> and see if the xgps will pick up the GPS signal from the Pi server. It should display a nice GUI with a map and positions, clock etc.  The program gpsmon can be used locally on the Pi to see if it provide sensible data.

The server will happily accept connections from OpenCPN. This enable several clients to use the GPS. Setting up OpenCPN is really easy, it even has a selection for gpsd in the connection under the connection button. Yet another connection removed from the USB on the laptop which can be moved freely around the boat.