Raspberry Pi Zero GPS Logger
This page contains (minimal) instructions and sources needed to reproduce the little Raspberry Pi GPS logger I'm currently playing with:
What you need:
- A Raspberry Pi Zero W with a case
- A USB GPS dongle with a ublox chip, preferably a VK172 dongle as shown in the picture.
- A USB battery pack with a micro USB connector.
- A USB OTG cable to connect the dongle.
- The scripts and libraries in this ZIP archive.
The simplest thing is to get a Pi Zero W starter kit, which typically includes a case and a cable.
Here's a very brief summary of what you need to do:
- Install a current version of Raspbian on the Pi (I used Raspian Stretch).
- Change the password for the default user. You can start by connecting the Pi to a monitor or TV with an HDMI cable, and hook up a mouse and keyboard through a USB hub, or configure it to allow SSH and connect through a terminal program. There's lots of instruction on the web how to do these things. Note that you'll probably need a mini-HDMI adapter on the Pi side to connect it to a TV or monitor.
- Configure the Pi to connect to your WiFi network.
- Install any tools that make working with the Pi easier. For Windows users, that may be Samba and a VNC client; for Mac users, I'd suggest to install netatalk, and to configure the VNC server on the Pi so the "Share Screen" button shows up in Finder windows.
- Extract the contents of the ZIP archive from above into the /home/pi/Documents/ folder. The scripts and jar files should be directly in your "Documents" folder (not in a "PiLogger" subfolder).
- Edit the /etc/rc.local file to add a line that starts the "start_logger.py" script at startup. An example of the rc.local file is included in the ZIP archive, but the changes must be made in the file in /etc/.
- Reboot the Pi.
If you've done everything right, the Pi will patiently wait for a USB GPS dongle to be connected, checking every 4 seconds (check the start_logger.py script for details). Once a dongle is connected, a little Java program will be started that configures the ublox chip, and then dumps all the data it gets from the GPS dongle into a file inside the "PiLogger" folder in /home/pi/Documents/. You stop the logging by disconnecting the USB dongle. A couple of minutes later, the Pi will be shut down. Don't pull the power before the shutdown is done - that can corrupt the SD card!
Here's a list of what's in the ZIP archive:
- rc.local: an example of how you have to edit you /etc/rc.local file
- start_logger.py: a Python script that waits for the dongle to be connected, and then starts the Java application that communicates with the dongle
- PiLogger.jar: a jar file with the compiled Java sources for the logger program
- logging_done.py: a script that is called after the dongle is disconnected to shutdown the Pi
- RXTCcomm.jar and librxtxSerial.so: two library files needed for communication with the USB dongle from the RXTX library
- PiLogger: A subfolder where the .ubx log files will be saved. It contains the settings file PiLoggerSettings.txt, which allow you so set a few logging parameters (e.g. Hz rate).
All files are distributed as free software without any warranties. The RXTX library files are covered by the LGPL license as shown here.