A while ago I wrote about getting myself a GPS unit to be able to record the routes I ride on my bike. I finally decided to get a Garmin Edge 205. It is mainly designed for biking but you can of course use it for navigation or geocaching as well.
I don't want to go into any detail about the features of the device itself. It's easy to use and besides recording the route, speed, and elevation profile it is also able to calculate your energy consumption based on your size, age and weight. The more interesting question is: Does it work under Linux?
The answer is: It does! In fact it works really well. All you need to access it is gpsbabel, the Swiss army knife for GPS data (which is also available for Windoze). Recent Linux kernels also contain a driver module named garmin_gps but gpsbabel doesn't work well with it. I wasn't able to read any data from my device as long as the kernel module was loaded. But that's no problem at all because gpsbabel is able to natively talk to the Garmin Edge 205.
In order to keep udev from loading the kernel module whenever you plug in the device you have to blacklist it. On Arch Linux this is simply a matter of adding !garmin_gps to the list of modules in your /etc/rc.conf.
MODULES={ ... !garmin_gps}
After making sure that the aforementioned module isn't loaded anymore it's time to check if the device is detected by gpsbabel. To do that simply connect it to your computer and run the following command:
% sudo gpsbabel -i garmin -f usb:-1 Password: 0 3309180752 450 EDGE205 Software Version 2.40
The option -f usb:-1 tells gpsbabel to scan and list all connected devices. In case you have more than one, you can specify which device you'd like to access ie. -f usb:0. If you omit the device id, -f usb:, gpsbabel will use the first device it finds (that's useful if you only have one device).
After verifying that gpsbabel found the GPS unit you can try to read the stored track data (I don't know much about the various gps data formats yet - but after reading the man page of gpsbabel I decided that the GPX format suits me best).
% sudo gpsbabel -t -i garmin -f usb: -o gpx -F test.gpx
If everything works well you should end up with a file named test.gpx that contains a lot of XML style data. If not you can increase the verbosity of the above script by adding the debug option -D2.
One not so nice thing about the above command is that it will fetch all data on the Garmin Edge 205 and store it in one single file. gpsbabel supports various filters which you can use to limit the amount of data which is fetched. In our case the interesting filter is the one to manipulate track lists. This filter supports a start/stop option which enables you to limit the saved data to a given time range.
The following command reads all track data recorded on 2007-10-20 between 1AM and 23PM and drops everything else which is not in this time range:
% sudo gpsbabel -t -i garmin -f usb: -x track,start=2007102001,stop=2007102023 -o gpx -F 20071020.gpx
Remembering all that every time you want to fetch some data from your Garmin Edge 205 isn't really nice so I wrote a little script. It accepts one parameter in the form YYYYMMDD. This way you can specify the date for which the data should be fetched. If you omit this parameter, it will fetch the data of the current day instead . The script also defines a directory where the files are stored. If you intend to use this script you have to modify it to your needs. The script also checks if the generated .gpx doesn't contain any track data (that's the case if the file is exactly 9 lines long) and deletes these files instantly.
#!/bin/sh # @author Michael Klier <chi@chimeric.de> # small tool to import gps track info from a garmin edge 205 GPS_DIR=/home/chi/gps GPS_BIN=/usr/bin/gpsbabel if [ "$UID" != "0" ]; then echo "ERROR: only root can run this script" exit 1 fi if [ ! -n "$1" ]; then DATE=$(date +%Y%m%d) else DATE=$1 fi cd $GPS_DIR $GPS_BIN -t -i garmin -f usb: -x track,start=${DATE}0001,stop=${DATE}2359 -o gpx -F ${DATE}.gpx if [ -f ${DATE}.gpx ]; then # "empty" track files contain exactly 9 lines if [ $(cat ${DATE}.gpx | wc -l) == "9" ]; then rm ${DATE}.gpx else chown chi:chi ${DATE}.gpx fi fi exit 0
As always, this script isn't foolproof or perfect
! Here's an example on how to invoke it:
% sudo gpsimport.sh 20071020 % ls ~/gps 20071020.gpx
So that all-together is nice - but it would be even nicer if we could just plug in the device after a trip and the data for the current day would be fetched automatically. Thanks to udev this is absolutely no problem. But in order to write an appropriate udev rule we have to find out some relevant data about our device first. You could do that by using udevinfo which is a command line tool provided by udev itself. But it's not that intuitive to use when it comes to USB devices. A better tool to do that is usbview (must be run as root).
The above output of usbview tells us that the vendor id of our device is “091e”. That's everything we need to write a custom udev rule.
On Arch the udev rules are located under /etc/udev/rules.d/. We will store our own rules in a separate file /etc/udev/rules.d/95-user.rules. The corresponding rule to add to this file looks like this:
# Garmin Edge 205 Data Import
ACTION=="add", SUBSYSTEM=="usb_device", ATTRS{idVendor}=="091e", RUN="/home/chi/bin/gpsimport.sh"
As you can see the rule triggers the above script whenever we plug in the Garmin Edge 205 to our computer. After adding the new rule we have to restart udev. On Arch this is done by executing /etc/start_udev.
That's it! Whenever you plug the Garmin Edge 205 to your computer the udev rule will be triggered and the GPS track data of the current day will be imported to your ~/gps directory
.
I ordered it online and it was about 217€. Compared with the price and functionality of some other GPS units I think it's an appropriate price. Garmin also released the Edge 605 lately which supports topographic maps - but it costs double as much as the 205
.
Well done sir, well done indeed. I just purchased one of these fine devices today and was looking to extract my ride data into .gpx format. This is a great help as you have seem to have done it for me and I won't have to resort to Windows, as all my computers run some flavor of Linux. I am looking online and seeing sites that will port a .gpx file to a route mapped out on Google Maps. Sadly these cost yearly fees and from what I hear it may be easy enough to just use the Google Toolkit and create your own program. This is something I think I will be doing soon (depending on the difficulty). Let me know if you are interested or have any good places you surf to!
Hi Brandon,
thanks for the comment
. Regarding your gpx2googlemaps question: qpsbabel should be capable of converting gpx into kml format. I am also using viking at the moment. It's a nice tool that allows you to edit your tracks and supports a wide range of maps including google maps. It uses its own file format though, but again, you can convert that to kml with gpsbabel too. Apart from that there's www.gpsies.com which allows you to import the track data from your Garmin edge directly via a Firefox extension (Windoze only
), alternatively you can upload gpx files as well and I think they offer kml downloads after you added a track - and it's free
.
Excellent - thanks, I'd fiddled occasionally throughout the day, but finding this page got the right commands to gpsbabel and it really was easy.
http://www.trimbleoutdoors.com/ is well worth a visit for keeping track of the data.
John
Not affiliated with trimble at all, just thought it looked like a decent interface, and their support forums seem to suggest that if you want something it will get done…
Very interesting. What was the price tag?