Skip to content

Instantly share code, notes, and snippets.

@dwhacks
Last active December 22, 2015 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dwhacks/6500046 to your computer and use it in GitHub Desktop.
Save dwhacks/6500046 to your computer and use it in GitHub Desktop.
#include <TinyGPS.h>
#include <SD.h>
/* This sample code demonstrates the normal use of a TinyGPS object. */
TinyGPS gps;
/* On Teensy, the UART (real serial port) is always best to use. */
/* Unlike Arduino, there's no need to use NewSoftSerial because */
/* the "Serial" object uses the USB port, leaving the UART free. */
HardwareSerial Uart = HardwareSerial();
//Set the pins used
#define led2Pin 15 //Write to SD
#define led1Pin 16 //Indicate we have a fix
void gpsdump(TinyGPS &gps);
void printFloat(double f, int digits = 2);
#define BUFFSIZE 90 //90
char buffer[BUFFSIZE];
uint8_t counter = 0;
bool gotGPRMC; //true if current data is a GPRMC strinng
void setup()
{
Serial.begin(115200);
Uart.begin(38400);
pinMode(led1Pin, OUTPUT);
pinMode(led2Pin, OUTPUT);
}
void loop()
{
bool newdata = false;
char c;
// Every 5 seconds we print an update
while (Uart.available()) {
c = Uart.read();
buffer[counter] = c;
gotGPRMC = strstr(buffer, "GPRMC"); //GPRMC
if (gotGPRMC)
{
Serial.print(buffer);
}
//Serial.print(c); // uncomment to see raw GPS data
if (gps.encode(c)) {
//newdata = true;
// break; // uncomment to print new data immediately!
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment