Build a GPS logger

1. Intro

This is an example showing how to build a simple GPS logger with Ansteron Board, GPS module and micro SD card. Location data is stored into a file on micro SD card in GPX format. Your path can then be viewed by importing that file into Google Earth or other similar software. A detailed log of your trip can be recorded with this device.

2. Building hardware

Beside the main parts, GPS module and micro SD breakout, there is an indication LED and a push button to start and stop logging. Everything is put together on a prototype board.

The prototype board is mounted on top of Ansteron board using 4 small copper wires. They are strong enough to hold the board but flexible so that prototype board can be moved side way a little bit to give access to the screws. They are also power supply lines connecting to GND and +5V pins of Ansteron Board.

The circuit is simple. Micro SD breakout connects with Ansteron Board via SPI bus. GPS module TX pin is connected to pin C0. LED is on pin D2 and push button is pin C3.

3. Software

GPX file format is based on XML. The example file below is minimum structure used in this project. The header will be written into file when logging starts. Each location point is then written as a line seen in data section. And when logging has finished, the ending will be written to wrap up data file.

This is a function in the program which starts a logging session:

Each record of Location data is built from Latitude and Longitude data using function below. Result is written in a global buffer and then be transfered to SD card with function SD_write_string().

When logging has finished, ending tags will be then written to data file in a similar way as header. Function SD_close_file() is then called to finalize data file on SD card and it is ready for viewing on computer.

4. Logging and viewing data

A logging session starts when the button is pressed and stops when the button is pressed again. The LED signals when button pressing is detected and blinks when GPS data is received during logging.

This GPS logger can be powered from battery. It consumes about 70 mA of current and a 9-volt alkaline battery (~500mAh) can be good for up to 7 hours of logging. Note that logging session must be ended to close data file before removing power. Otherwise, some data may be lost.

Data file on SD card can be transferred into a computer and viewed with Google Earth or similar software that support GPX files. The example below is a track viewing with Google Earth (remember to check option "Create KML LineStrings" to visualize your track as a string of points).

5. Note

GPS module used in this project output 1 update every second. The program implemented a divider so that one point is written to file every 5 seconds. Depend on the speed you travel, change divider value (prescaler) in source code to compromise between detail and data size.

Source file for this project is included in example folder of Ansteron IDE. The original version only supports one track file and the file will be over-written each time. Another version added multiple files support. Each logging session is stored in a different file, up to 255 files. See source file for detail.