GPS
Records position, speed and heading from a BerryGPS receiver on the Raspberry Pi, with the raw NMEA sentence in every row.
This module is written for the BerryGPS and BerryGPS-IMU from OzzMaker on a Raspberry Pi. Other receivers that send NMEA sentences over a serial port may work but have not been tried. The Raspberry Pi version of RSLogger is supplied on request, see Getting started.
Getting started
- Connect the receiverTo the Pi’s UART header, see Hardware setup.
- Give it a view of the skyA receiver that has been off for a while can take a minute or two to find satellites.
- Enable the moduleCheck GPS in the Modules menu, then click the receiver in the Devices panel.
- Wait for a fixThe telemetry panel shows the fix state and the satellite count.
- RecordStart a session and click Record.
The GPS window
The map shows the current position as a dot with a trail of recent positions, on map tiles stored on the Pi so that it works with no internet connection. The telemetry panel shows latitude and longitude, speed, heading, altitude, the satellite count and the fix state.
What is written
One CSV per receiver for the whole session, in the GPS folder. Each row is one NMEA sentence from the receiver, so at the BerryGPS default of one update per second there are several rows per second, one for each sentence type the receiver sends.
{session_dir}/GPS/{token}_GPS_serial0.csv GPS CSV, 25 columns
| Column | Description |
|---|---|
trial | Trial number |
module | GPS |
device_id | The receiver |
label | The trial label, if any |
record_time_unix | Host wall-clock time when the sentence was parsed, six decimals |
record_time_mono | Host monotonic clock at the same instant, nine decimals |
device_time_unix | The UTC time carried in the sentence, as seconds since the Unix epoch. Empty when the sentence has no time field |
latitude_deg, longitude_deg | Decimal degrees. North and east are positive |
altitude_m | Altitude above mean sea level, metres |
speed_mps, speed_kmh, speed_knots, speed_mph | Speed over ground in four units |
course_deg | Course over ground, degrees from north |
fix_quality | NMEA fix quality. 0 none, 1 GPS, 2 differential |
fix_mode | Text. No fix, 2D or 3D from a GSA sentence, or the mode letter from an RMC sentence |
fix_valid | 1 when the receiver reports a valid fix, 0 otherwise |
satellites_in_use, satellites_in_view | Satellites in the solution, and visible |
hdop, pdop, vdop | Horizontal, position and vertical dilution of precision. Lower is better geometry |
sentence_type | RMC, GGA, VTG and so on |
raw_sentence | The sentence exactly as received, for reprocessing with other tools |
Each sentence type carries only some of the fields. RSLogger keeps a running snapshot of the fix, updates it from every sentence, and writes the whole snapshot each time, so a row holds the latest known value of every field. sentence_type and raw_sentence say which sentence produced the row. A field stays empty until a sentence that carries it has arrived.
Example row
1,GPS,GPS_serial0,,1774149567.500000,373235.004822011,1774149567.000000,40.7608,-111.891,1300.5,12.3,44.3,23.9,27.5,185.2,1,3D,1,8,12,1.2,1.8,2.1,GGA,"$GPGGA,031927.00,4045.648,N,11153.460,W,1,08,1.2,1300.5,M,,,,*15" Timing
device_time_unix is the time of the fix as the receiver stated it, derived from the satellites and independent of the Pi’s clock. record_time_* is when the sentence reached RSLogger, which is later than the fix by the time the sentence took to travel over the serial link at 9600 baud, plus the receiver’s own processing. RSLogger does not measure that delay and does not use the receiver’s pulse-per-second output.
Use record_time_mono to line GPS rows up with other modules on the same Pi, and device_time_unix when you need the time of day of a fix. Do not treat the difference between the two as a measurement of anything.
Settings
File > Configure… in the GPS window.
| Setting | Default | Notes |
|---|---|---|
| Serial port | /dev/serial0 | The Pi’s hardware UART. A USB-serial adapter appears as /dev/ttyUSB0 or similar |
| Baud rate | 9600 | The BerryGPS default. Change it only if you have reconfigured the receiver |
The update rate is set on the receiver, not in RSLogger. The BerryGPS ships at one update per second.
Offline maps
The map uses tiles stored in a database inside the module, so it needs no connection while you record. Download tiles for your area beforehand, with an internet connection, from File > Download Map Tiles… in the GPS window. The same download runs from the command line:
python -m rslogger.modules.GPS.tile_downloader --center 40.7608 -111.8910 --radius 15 The tiles are stored in rslogger/modules/GPS/offline_tiles.db.
Hardware setup
The BerryGPS sits on the Raspberry Pi’s GPIO header and talks over the hardware UART at /dev/serial0. OzzMaker’s quick start guide covers fitting it and the antenna.
To free the UART for the receiver:
- In
raspi-config, under Interface Options > Serial Port, answer No to a login shell over serial and Yes to enabling the serial port hardware. - Reboot.
- Check that
/dev/serial0exists.
You can confirm the receiver is talking before you start RSLogger by reading the port with a terminal program at 9600 baud. Lines beginning $GPRMC and $GPGGA mean the wiring and the baud rate are right, even before the receiver has a fix.
Troubleshooting
The receiver is not detected
Check the wiring and that /dev/serial0 exists. Read the port with a terminal program to confirm sentences are arriving. Check that the baud rate in the settings matches the receiver.
No fix
Move to a spot with a clear view of the sky and wait. A cold start can take a couple of minutes. Check the antenna connection if you are using an external antenna.
The position wanders
Look at satellites_in_use and hdop. Fewer than four satellites, or a high HDOP, means poor geometry. Move away from buildings and trees, or use an external antenna with a better view.
The map is blank
Download tiles for your area with an internet connection, then try again. Check free disk space.