NMEASentence \ Learning \ Wiring ALPHA 1.0
Author: Hernando Barragán
Description: Wiring is an electronic sketchbook and hardware electronics for developing ideas. It is a context for learning fundamentals of computer programming and prototyping with electronics within the context of the electronic arts.
Keywords: Wiring, Processing, Interactive Media, Electronic Arts, Programming, C, C++, Hernando Barragán

Search wiring.org.co:

This example is for Wiring version 0023+. If you have a previous version, use the examples included with your software. If you see any errors or have comments, please let us know.

This example illustates access to all sentence types, using the NMEA library. It assumes that a GPS receiver is connected to serial port 'Serial1' at 4800 bps.

    #include <nmea.h>

    NMEA gps(ALL);    // GPS data connection to all sentence types

    void setup() {
      Serial.begin(9600);
      Serial1.begin(4800);
    }

    void loop() {
      if (Serial1.available() > 0 ) {
        // read incoming character from GPS and feed it to NMEA type object
        if (gps.decode(Serial1.read())) {
          // full sentence received
          Serial.print ("Sentence = ");
          Serial.println (gps.sentence());
          Serial.print ("Datatype = ");
          Serial.println (gps.term(0));
          Serial.print ("Number of terms = ");
          Serial.println (gps.terms());
        }
      }
    }