Libraries \ NMEA

Reference for Wiring version 1.0 Build 0100+ If you have a previous version, use the reference included with your software. If see any errors or have any comments, let us know.

Class

NMEA

Name

gprmc_speed()

Examples
#include <nmea.h>

// create a GPS data connection to GPRMC sentence type
NMEA gps(GPRMC);

void setup() {
  Serial1.begin(4800);
  pinMode(8, OUTPUT);
}

void loop() {
  if (Serial1.available() > 0 ) {
    // read incoming character from GPS
    char c = Serial1.read();

    // check if the character completes a valid GPS sentence
    if (gps.decode(c)) {
      // check if GPS positioning was active
      if (gps.gprmc_status() == 'A') {
        // read speed in kilometers-per-hour and set led accordingly
        if (gps.gprmc_speed(KMPH) > 50.0) {
          digitalWrite(8, HIGH);
        } else {
          digitalWrite(8, LOW);
        }
      }
    }
  }
}
Description Returns speed-over-ground of GPS. To get the speed in kilometers-per-hour, use gprmc_speed(KMPH). Possible units of speed are KMPH for kilometers-per-hour, MPS for meters-per-second, MPH for miles-per-hour, and KTS for Knots.
Syntax
gprmc_speed(unit)
Parameters
unit KMPH, MPS, MPH, or KTS
Returns float
Usage Application
Updated on July 07, 2011 11:11:11pm PDT

Creative Commons License