Building a GPS Logger

I like hiking, its a good excuse for getting outside, exploring the countryside, getting fit and having fun. While I can remember the places I’ve been and have photos as well, I would like to be able to record more information about the hike and be able to display the route taken in mapping applications. I have previously used a Laptop and USB GPS receiver in the car to record camping trips, however this is impractical when hiking as weight is an issue and the laptop battery only lasts a few hours.

Project Requirements

For the logger to be useful it must:

  • be lightweight and portable. I envision it being strapped to my arm in a similar fashion to joggers and their iPods.
  • be able to record for several days, up to a week. Hikes like the Bibbulmun Track can take several weeks if attempted in one go.
  • be rechargeable.
  • have an easy method of getting the data onto a PC.
  • have a simple to use interface.
  • be water resistant. It must continue to function properly in the rain.

These requirements are arbitrary at the moment. Numbers and data will be placed against the requirements later on in order to make design decisions.


Initial constraints that will be placed on the project are:

  • PIC18F4550 Based. This places a limit of 2048 bytes of SRAM, 32K of Flash for code and 256 bytes of EEPROM.
  • SD card for data storage. Cheap, spacious and easy to use, however requires an SPI port, can be bit-banged.
  • USB for charging and data xfer (Mass Storage Class). The PIC supports this natively.
  • SiRF-II based 12 channel GPS receiver. Requires a hardware UART for RX/TX.
  • All code will be written in MPLAB for the C18 C compiler.

These constraints are based upon what I currently have on hand, in order to minimise cost and simplify the project. There probably are devices better suited to the task out there somewhere.

User Interface and Operation

The user interface will consist of a single button and several LEDs or a RGB LED through which all user communication will occur.  An overview of the proposed system states and transitions is given below.

An overview of the system states

Pressing the button will wake the device up from sleep and put it into operating mode. If the button is pressed and released in the operating mode, a waypoint of the current position is recorded into the log. Pressing the button for 3 seconds will put the device to sleep. The device will also go to sleep when in the same location for 5 minutes. Data logging will stop when the device is connected to a computer or GPS lock is lost. The GPS receiver will stay powered up while the device is in the sleep state to maintain signal lock until the battery level gets critical. The SDCard will be powered down during sleep. Coming out of sleep mode will create a new log file.

The LEDs will

  • show when the battery is getting low. This will probably be a flashing red LED.
  • indicate the quality of the GPS information. Flashing for a 2D or less lock and on for a 3D lock. This will probably be a green LED.
  • indicate the 1 second pulse from the GPS receiver. This will probably be another green or a blue LED.

Initial Prototype

A schematic of the prototype hardware is presented below and include the PIC, GPS interface, SDCard Interface, USB, Voltage regulation and User interface. Missing from this version of the prototype is a battery, voltage monitoring and charging circuit.

Prototype schematic for the GPS logger.

The initial software will consist of the data logging part only, to assess the viability of the project and to provide data for some of the requirements. Battery monitoring will be implemented but not control anything to provide better power usage figures. The software will be written in the following order:

  1. System initialisation.
  2. USART setup and GPS SiRF-III protocol implementation.
  3. Implementation of bit-banged SPI and SD Card interface.
  4. FAT-16 support for writing files.
  5. State control and user interface.
  6. Mass Storage Controller class device driver for USB.
  7. Battery monitoring.

Each section will be tested and confirmed working before the next section is started on. Once all sections are complete, the prototype will be used to gather power usage in order to design the final system and battery requirements.

Continue on to part II

, , , , ,

  1. #1 by shalini on February 24, 2012 - 5:45 pm

    hi, is it possible to build the same project using MBED microcontroller?

  2. #2 by nada on February 24, 2012 - 8:43 pm

    After a quick glance, the MBED has 2x SPI interfaces which is great for using an SD-Card. However, from what I can see, it has no asynchronous ports that are compatable with RS232. Interfacing to the GPS module could be tricky in this case, but not impossible. I did see a tutorial somewhere (Hackaday?) that describes how to use a SPI serial port as an 8-bit rs232 receiver.

    SPI communications (for the SD-Card) are much easier to implement in software than the asynchronous comms used with GPS modules. If on change interrupts are not available then you’re probably out of luck.

(will not be published)