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

decode()

Examples
#include <nmea.h>

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

void setup() {
  Serial1.begin(4800);
  pinMode(0, 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') {
        // check if you are in Colorado, USA
        boolean inColorado = (gps.gprmc_latitude() > 37.0)
                          && (gps.gprmc_latitude() < 41.0)
                          && (gps.gprmc_longitude() < -102.05)
                          && (gps.gprmc_longitude() > -109.05);

        // set led accordingly
        if (inColorado) {
          digitalWrite(0, HIGH);
        } else {
          digitalWrite(0, LOW);
        }
      }
    }
  }
}
Description Decodes character received from the GPS. Returns 1 when the character completes a sentence, returns 0 otherwise. If the connection type is NMEA(ALL), every complete sentence is detected. If the connection type is NMEA(GPRMC), only sentences of type GPRMC are detected.
Syntax
decode(c)
Parameters
c char
Returns int
Usage Application
Updated on July 07, 2011 11:11:09pm PDT

Creative Commons License