Raspberry Pi & GPS

This is very much work in progress. We are documenting stuff here as we go.

Start with the following commands:
sudo apt-get upgrade
sudo apt-get update


BlueNEXT GPS USB dongle
We bought this BlueNEXT USB GPS device to try out.

Plugging this in and typing lsusb showed a new entry:
Bus 001 Device 006: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light

sudo apt-get install gpsd
sudo apt-get install gpsd-clients


The command ls /dev showed we now had a new device called gps0.

Typing the command: ls /dev/ttyUSB* shows we have a dev: /dev/ttyUSB0

If you just want to do a quick check to see what data is coming out of the GPS, you can enter the following command, following by CTRL+C to quit:
sudo cat /dev/ttyUSB0
Didn't show anything. This is down to a bug in the way the Raspberry Pi and GPSD work.

Point the gps daemon to our GPS device on the USB to TTY adapter:
sudo gpsd /dev/ttyUSB0 -F /var/run/gpsd.sock


We are using this USB serial module as we had it lying around.

Plugging it in and typing lsusb showed a new entry:
Bus 001 Device 009: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port

Before we progressed further, we checked our system was up to date with the sudo apt-get update command.

We then installed the GPSD with the sudo apt-get install gpsd command.

We also installed the GPSD clients with the sudo apt-get install gpsd-clients command.

We then restarted the Raspberry Pi.

The command ls /dev showed we now had a new device called gps0. The command gpspipe -r ...


The next step is to check you are getting useful GPS data out of the hardware. Obviously, you need to be outside for this. We did our testing with the GPS USB dongle on the end of 3m USB extension cable, leading outside through a window and this seems to work well. It also works on the inside window sill:
cgps -s

Note: If you have any problems and cgps always displays 'NO FIX' under status and then aborts after a few seconds, you may need to restart the gpsd service. This is a known bug.

Graphical View

If you have started the graphical environment (using the startx command), the you can also run a graphical viewer to view the GPS data. The command is xgps.

Setting The Time Using GPS

This is done using the command: sudo apt-get install ntp but, it was already installed with out O/S build.

Edit the file: /etc/ntp.conf and add the lines:
# gps ntp
server minpoll 4
fudge time1 0.183 refid NMEA
server minpoll 4 prefer
fudge refid PPS

Restart the ntp service: sudo service ntp restart


Our Dashcam project is a good example of using Python code to access the GPS data.

Known Bugs

Like many others, we struggled to get the GPSD daemon to see our USB GPS device. There seems to be a bug in connecting to the ttyUSB0 port.

The annoying work-around appears to be to restart GPSD:
sudo killall gpsd
sudo gpsd /dev/ttyUSB0 -F /var/run/gpsd.sock

If you are using it to set the time, you also need to restart the NTP service:
sudo service ntp restart

Share ...
We are on ...
Facebook Twitter
YouTube Flickr Follow us on Pinterest