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_longitude()

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') {
        // 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(8, HIGH);
        } else {
          digitalWrite(8, LOW);
        }
      }
    }
  }
}
Description Returns longitude of GPS position. The longitude is returned as decimal degrees. A positive value indicates East of Greenwich (UK), a negative value indicates West of Greenwich. For example, Sydney (Australia) is located around 151.209472 decimal degrees longitude, which is 151.209472 degrees East of Greenwich.
Syntax
gprmc_longitude()
Returns float
Usage Application
Updated on July 07, 2011 11:11:10pm PDT

Creative Commons License