Raspberry Pi Python Garmin Strava

Overview

I like running.

I have a Garmin Forerunner 10 GPS watch that I use to track my times.

This watch can plug into a computer via its USB cradle.

Using a Raspberry Pi, I have built a system to detect when the watch is plugged in, and automatically detects new runs and uploads them to Strava via its API.

The Raspberry Pi uses a custom udev rule to detect the watch:

1
ACTION=="add", ENV{DEVTYPE}=="usb_device", ATTRS{idVendor}=="091e", ATTRS{idProduct}=="25ca", RUN+="/home/pi/pi-python-garmin-strava/bash/on-garmin-add-trigger.sh"

This in turn trigger a bash script that activates a virtualenv environment and runs a Python script:

1
2
3
4
DIRPATH='/home/pi/pi-python-garmin-strava'
source $DIRPATH/env/bin/activate
$DIRPATH/env/bin/python $DIRPATH/upload.py $DIRPATH
deactivate

(Absolute paths weren’t necessary, but they made life easier.)

The Python script is responsible for accessing files on the watch, and interacting with the Strava API.

Full setup notes are on Github and my Strava account is here

Photos