Sounds like a nice project. If you don’t have a GPS module yet, take a look at the ublox NEO-6M, 7M or M8N. They are fairly common and start at less than $20 or so.
what I do is to write a code to print the result from the “GPRMC NMEA” to see how to extract the speed.
Yes, you could write your own “parser” to watch for a particular sentence (GPRMC), a particular field in that sentence, and verify the checksum.
Or you can use a library to parse the incoming bytes into the various values like lat/lon, time or speed. I do not recommend the Adafruit_GPS library, because it is very inefficient, it uses a lot of RAM (1/3rd of the UNO’s 1K!), and it does not verify the checksum of the sentence. This can allow bad values to be passed to your sketch.
I wrote the NeoGPS library to be very small, efficient and configurable. It could use as little as 28 bytes for your sketch. By default, it adds 115 bytes, still much less than other libraries. Here is a simple sketch that prints just the speed value:
#include <Arduino.h>
#include "NMEAGPS.h"
#include <AltSoftSerial.h>
AltSoftSerial gps_port; // always 8 and 9 on the UNO
NMEAGPS gps;
gps_fix fix;
//--------------------------
void setup()
{
// Start the normal trace output
Serial.begin(9600);
while (!Serial)
;
Serial.print( F("GPS Speed Limit\n") );
// Start the UART for the GPS device
gps_port.begin( 9600 );
}
//--------------------------
void loop()
{
while (gps.available( gps_port )) {
fix = gps.read();
if (fix.valid.speed) {
Serial.print( fix.speed_kph() );
} else {
// No data yet
Serial.print( '?' );
}
Serial.println();
}
}
Just sitting still, this will print random speed values, up to 1.5kph or so.
Also, be sure to use pins 8 & 9 for the GPS device so you can use the AltSoftSerial library:
#include <AltSoftSerial.h>
AltSoftSerial gps_port; // always 8 and 9 on the UNO
Pin 8 will receive data from the GPS TX pin. Pin 9 will transmit configuration commands to the GPS RX pin (optional).
If you really can’t use those pins, I would recommend NeoSWSerial, a library I maintain. I don’t recommend SoftwareSerial.
Cheers,
/dev