Arduino-Powered GPS Speedometer

You can easily interface a GPS chip like this one with an an Arduino micro-controller and make some pretty cool projects. I decided to make a simple speedometer/odometer for my bike. For this to work, we need to retrieve the relevant data from the GPS module, then process it using the Arduino before outputting it to the LCD screen. The device will also need to be powered by a battery so we can carry it around freely. 

The receiver has two serial pins which send and receive data, both of which are connected to ports on the Arduino that have been programmed to send(TX) and receive(RX) serial data. 

We can send commands to the receiver using the Arduino's TX pin to set things like the GPS update rate and so on. For example, the following line sets the update rate to 5 hertz:

#define PMTK_SET_NMEA_UPDATE_5HZ  "$PMTK220,200*2C" 

Now, the module reads out strings of data in NMEA sentences five times a second to the Arduino that look like this:

$GPRMC,092751.000,A,5321.6802,N,00630.3371,W,0.06,31.66,280511,,,A*45

Each value separated by a comma represents, in order, 
      1   092751     Time Stamp
      2   A          validity - A-ok, V-invalid
      3   5321.6802  current Latitude
      4   N          North/South
      5   00630.3371 current Longitude
      6   W          East/West
      7   0.06       Speed in knots
      8   31.66      True course
      9   280511     Date Stamp
      10  A*45       checksum

You can do a lot of things with this data, but we'll just be using the speed.
It is easy enough to parse through the string with our code to pick out the data we want.
Here is a simple function that isolates the different data by using the commas as separators.

void dataParse(int section) {    
  char nextChar;
  int commas = 0;
  resetReturn();
  for (int x = 0; x <= dataStr.length(); x++) {
    nextChar = dataStr.charAt(x);
    if (nextChar == ',') {
     commas++;
     continue;
    }
    if (commas == section) {
  returnStr.concat(nextChar);
    }
    else if (commas > section) {
 break;
    }
  }  
}
Since we want the speed for the odometer, we will parse for the data after the 7th comma.The full code can be found here. To make things easy, we'll hook up the Arduino to an LCD screen via Serial LCD. With Serial LCD, the Arduino can drive an LCD screen with only a single serial wire. With the LCD connected, we're set.

Now all that's needed is the power, which you can do pretty easily by hooking it all up to a
9V battery.