Open Source GPS HOW TO

Using a Garmin Edge to Plot Cycle Routes with Google Maps on Linux, Macs and Windows

By Martyn C Davis, 14-MAY-2006

On a recent organised cycling ride in the Test Valley down in Hampshire (I'm in the UK), a friend showed me his new toy; a Garmin Edge 305 GPS-enabled bike computer. Being a bit of a gadget head I'd played around with GPS on bike rides before, but the old Garmin GPS 12 I'd had seemed almost the weight and size of a brick, it had a serial interface, and the best use I ever really got out of it was to tell me what my coordinates were, which I could then check back onto an OS map. It also had a hard time finding a signal when surrounded by tall buildings or tree cover.

I often find it quite boring riding around the same old familiar routes on my bike, but the alternative, which is figuring out a new route, then stopping every few miles to consult the sweaty OS map in my back pocket spoils the tempo of the ride. My ideal scenario would be to figure out a route beforehand, program it into a GPS, and let it lead me through the new ride. Seeing this new Garmin model rekindled my desire to get this working.

The Edge from Garmin is about the size of a SMALL mobile phone, it's light, and it's sensitive: it picks up a signal almost anywhere you are going to ride. Ideal, I thought. My friend's model was the 305, which does either heart rate or cadence, and has a barometric altimeter built in. The cheaper model, the 205, lacks the HR / cadence, and relies on GPS to calculate altitude, which is less accurate. I have a Polar watch which does all this, so I was happy to go for the 205.

First Impressions

My first impressions were pretty negative. After I'd ordered it from Wiggle I started looking around for information on the unit (OK, I know I should have done the research before ordering the thing, but I ordered it in a moment of gadget lust :). All the information I was getting back from my internet searches were people griping about how Garmin are using proprietary formats and weren't being very helpful (see, for example, this O'Reilly article on the subject).

So I received the unit and had a pretty fruitless few days trying to bend it to my will. The software that comes with the device is crap. For one, it's a Windows application. I use Linux, and Mac OS, and run Windows approximately never, but I do keep one machine (referred to in this household as the toy machine which dual boots to allow me to test stuff and run games). Installing the Garmin software on this machine allowed me to have a brief look, and I didn't like it. It's not intuitive and it looks horrible. There's no way THAT's going to tempt me to use it. Also it's designed more for training than routing.

What do I want?

So, what do I actually want? I had a half-conceived idea that firstly I wanted to be able to use Google Maps to define a route. This would be fantastic, because not only can you zoom right in and out, but you can also see satellite imagery, which is becoming more and more detailed. This allows you to check a spot, say, to see whether it's a junction or just a bend in the road. I then would like to perhaps save that route to a GPX file (GPX is becoming an XML-based standard for GPS data transfer), which I could somehow then upload to the GPS unit. The supplied software and its help files make absolutely no mention of GPX, so (thankfully, as it's Windows) I shan't be using that.

NB: There is a site which is quite popular with cyclists called "GMaps Pedometer" which offers the ability to define routes. It's good, but it has a somewhat different aim. You CAN get GPX out of it, but only through another site and the use of a bookmarklet - hence, for GPS, it's kludgy. Also you have no control over waypoint names etc.

The Linux Approach

Plugging the Garmin unit into my Linux laptop (running Ubuntu "Breezy") via USB, and checking the system logs by typing "dmesg", I see a heartening series of messages:
    [4309364.676000] drivers/usb/serial/usb-serial.c: USB Serial support registered for Garmin GPS usb/tty
    [4309364.682000] garmin_gps 5-1:1.0: Garmin GPS usb/tty converter detected
    [4309364.726000] usb 5-1: Garmin GPS usb/tty converter now attached to ttyUSB0
    [4309364.726000] usbcore: registered new driver garmin_gps
    [4309364.726000] drivers/usb/serial/garmin_gps.c: garmin gps driver v0.23

Garmin USB support just works. Support is built into the kernel, so the device now sits on a pseudo-serial port called /dev/ttyUSB0. Hopefully I can find an application that will support it.

I tried a few applications without much success, and the one I kept coming back to was GPSBabel. The UNIX command-line-based version has about a million options and took a while to figure it out, but eventually I got it working. The command line required to transfer a GPX file to the unit is, assuming that your GPX file is called "foo.gpx":
    gpsbabel -r -i gpx -f foo.gpx -o garmin -F usb:

I've written a small script to wrap this call to make it a bit easier to remember. You can grab a copy here.

Generating the GPX File

Next problem: generating my own GPX files! The Google Maps API is fantastic - it's great that Google have allowed third parties to make their own applications around their mapping service. This is definitely the way forward, and it didn't take much hacking before I developed a small javascript prototype application which allows me to click on the map, define a set of waypoints, naming them as I went along, and then generate a GPX file from them, which uploads OK to the Garmin device. Here's an example, which, if you copy and paste into a file, you could use to test with GPSBabel and my script.
    <?xml version="1.0"?>
    <gpx version="1.1"
        creator="Marengo Route Creator"
            <rtept lat="51.44978141819847" lon="-0.29534339904785156">
            <rtept lat="51.45373948545901" lon="-0.2574920654296875">
            <rtept lat="51.42179772664755" lon="-0.28594493865966797">
            <rtept lat="51.44967443864507" lon="-0.2954292297363281">

The latest version of this application is now out. You can find it at

I welcome any feedback. Join the discussion at my blog: I'd love to hear from you even if it's only to tell me that you find the software useful.


My plans for the software are as follows:
  • Define routes (done)
  • Export as GPX (done)
  • Save to database (done)
  • Load from database (done)
  • Share routes with other users (done)


Well, reservations regarding the proprietary nature of Garmin aside, I have to say that now I've figured out how to plan routes and upload them to the device, I love it. It's got a quite loud beeper on it, to warn you of upcoming waypoints, and the battery life seems quite good. It charges via USB. If you are going on a long, multi-day trip, don't forget the charger, or your laptop and ITS charger. If you are going to be away from any electricity, there's always the USB Battery.

You can find the latest release of the GPX generation software at

Like I say, if you want to feed back any comments, please join the discussion at my blog:

I'll be interested to see how it works with other GPS units too - drop me a note to tell me what you've got it working with.

Finally, you may also contact me at my gmail address. Use my full name (including middle initial) as quoted at the top of this article, separated by dots (like, for example, "hector.h.monro", except with my name :), and append "" to it. Queries will be given much more attention if you accompany them with a small donation (see the PayPal link at the end of this page).

UPDATE: I've been asked by many people whether this is going to work under Windows. Good news... I've tested GPSBabel under XP and it does appear to. You can test this yourself by installing GPSBabel for Windows, and then, from wherever you installed the software, you can issue a command from the command line the following (assuming you've got the sample GPX file saved as "foo.gpx"):
    gpsbabel.exe -r -i gpx -f foo.gpx -o garmin -F usb:

There's a windowed version of GPSBabel available from their site too if you are not comfortable with using the command line. There is a version for Mac OS X as well. All these work in the same way.

The only downside I see so far is that the current version of the Windows version of GPSBabel (1.2.7) doesn't seem to support the NAME of the route... all routes get imported with a name of "EMPTY", which is a bit confusing when you look at the route list, as you think "EMPTY" means "I have no routes", but that's the name of the route... I know that this has been fixed in the Linux 1.2.8 Beta release, so hopefully the Windows version will also be fixed.

So this means that the application should allow BOTH Linux users and their unfortunate Windows brethren to both easily plot routes via Google Maps for the Garmin Edge devices. Cool.

Update 1-AUG-2006 For more information, please see the discussion blog at

Update 5-MAR-2007 I've been asked by many people how to do the opposite: get a recorded route OFF their GPS unit and onto the Marengo Route Planner. See this related HOW TO for more information:

If you found this HOWTO useful, please buy me a beer: