The Goal
The goal of this project was to create a cheap, simple GPS tracking system using cheap hardware and free/and or home grown software.
In a nutshell, a PC grabs the coordinates off a locally attached GPS device, uploads them with the use a Verizon EVDO wireless card to a web server that stores the coordinates in a MySQL database. Then, anyone on the Net can go to a web page (
http://unstable.aset.psu.edu/cjh/gps/ in this case) and see where I am at in the world. The web page utilizes the
Google Maps API and AJAX to track updates in real time.
Such a device could be placed in a car, Faculty shuttle or loop bus. An entire setup with dedicated PC costs around $700. If you choose not to go with a dedicated PC, it would just cost the price of a GPS receiver and a cell card.
The Box
Originally, I used my
Macbook Pro to read the coordinates off the GPS receiver. This works great if you don't want to buy a dedicated piece of hardware. After successfully prototyping the system with my laptop, I decided to buy one of those mini-PCs that are designed for use in cars. These mini-PC's continue to get faster, cheaper and less power hungry all the time. When wired properly, the box will turn on with your ignition and turn off when your car is turned off.
I settled on the
SolidLogic 3677 Mini-ITX Car System case which houses a
mini-ITX main board manufactured by
Via Technologies. The
EIPA MII 12000 motherboard was chosen because it includes both a CardBus slot (for the cell card) and a CompactFlash slot (for the OS).
The box runs Linux (Debian as the distribution).
The GPS
Any GPS that uses the
NMEA protocol should be sufficient. There are three GPSes that I tested successfully. They are Garmin Etrex Legend, Garmin Mobile 10 and the Delorme Earthmate LT-20.
To see if the GPS you have is supported by GPSD, check out the matrix
here. More on GPSD later.
The Cellular Card
All you really need is an IP connection to upload the coordinates. Any cell card, reliable municipal wifi (though this will severely limit your range) or cell phone data connection would work perfectly fine.
We purchased a Verizon PC5200 card, because the mini-ITX box only has a CardBus slot (it doesn't have an expresscard/34 like the Macbook Pro). An unlimited data plan from Verizon runs about $70/month.
The Mapping
The Google maps API is very well written and very easy to use. You have to sign up for a google maps API key before you can start using it on your web site. You can obtain one
here.
Including a good map into web page only requires a few lines of HTML and javascript.
The Software
Information from the GPS is recieved via some open source software called
gpsd.
I wrote some C code that you can get
here.
Some C code grabs the info from gpsd and uploads the coordinates via a simple HTTP GET request. The OS that runs on the mini-PC is linux (Debian, in this case but anything will do).
The machine boots up, connects to the internet via pppd, and starts uploading coordinates once it aquires enough satellites. It will reconnect to the network if it loses its connection. It's works very well.
So far, I have logged almost 100,000 coordinates in the database.
How it works
figure 1-1
Back-end Side
- Laptop reads current GPS coordinte off GPS receiver
- Laptop sends coordinate to web server via HTTP get request (ie http://unstable.aset.psu.edu/cjh/gps/addpoint.php?latitude=40.771727&longitude=-77.877098&time=1173280550&elevation=376.300000)
- Web server inserts coordinate into MySQL database
- Back to step #1
Front-end Side
- At this point, a client can go to the web page (http://unstable.aset.psu.edu/cjh/gps) and see where the trackee is
- Every 5 seconds, the client issues an AJAX request for the new coordinate
- Coordinate is updated on Google map in tracker's web browser
Source Code
There is some code you need to download:
- gpsd
- C code to retrieve GPS coordinates (compile with "cc -lgps qgps.c -o qgps")
- PHP code to install on web server
- SQL to create database and tables used to store GPS data
| Hardware cost breakdown |
| Solidlogic 3677 mini-ITX car system | $514 |
| Earthmate LT-20 | $99.99 |
| Verizon EVDO Card | ~$100 |
| total | ~$700 |