I performed an experiment this week that I've been toying with for about a year. Last March, I got a GPS receiver from a buddy of mine, and started playing with the idea of having my laptop send email check-ins to brightkite.com every 10 minutes.

Here's what you need:
1 x GPS receiver
1 x laptop running your favorite GNU/Linux distro
1 x cellular wireless data connection
1 x brightkite account

Here's my DeLorme GPS Receiver:
GPS

And my Comms Unit (including 3G data access):
NxCAS at work

And, the laptop:
Laptop

The most important bit is the scripts. First, we need to pull the data from the GPS receiver. Here's my FollowMe script:


#!/bin/bash
# $HOME/GPS/scripts/FollowMe.sh
# last updated: Thu Mar 17 22:00:10 EDT by slacker@tyr

# start gpsd as root
sudo gpsd -n /dev/ttyUSB1

DATE=`date +%y%m%d-%H%M%S`
mkdir ~/GPS/$DATE
GPSDUMPFILE=~/GPS/$DATE/dump.nmea
GPSDRIVEFILE=~/GPS/$DATE/dump.gpsdrive
RSLTFILE=~/GPS/$DATE/dump.rslt

# poll gpsd every $INTERVAL minutes
INTERVAL=10

X=1

while [ $X -eq "1" ]
do
echo rw | nc -i 3 localhost 2947 >> $GPSDUMPFILE
gpsbabel -i nmea -f $GPSDUMPFILE -o gpsdrive -F $GPSDRIVEFILE
CURRENTRESULT=`tail -1 $GPSDRIVEFILE`
# for debug
echo $CURRENTRESULT
LAT=`echo $CURRENTRESULT | awk {'print $1'}`
LON=`echo $CURRENTRESULT | awk {'print $2'}`
echo "@ $LAT,$LON" > $RSLTFILE
# email result to brightkite
mutt yrcode@bkite.com < $RSLTFILE
sleep `echo "$INTERVAL * 60" | bc -l `
done

To be honest, I was planning on being more detailed in this post, but now I'm not feeling it.

Anyway, the result was pretty sweet: lnxcwbyOtR on twitter and on brightkite. Oh, if there are any specific questions, lemme know :-)

0 comments:

Newer Post Older Post Home