Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include <TinyGPS++.h>
static const uint32_t GPSBaud = 9600;
// The TinyGPS++ object
TinyGPSPlus gps;
// The serial connection to the GPS device
HardwareSerial ss(2);
void setup(){
Serial.begin(9600);
ss.begin(GPSBaud);
}
void loop(){
// This sketch displays information every time a new sentence is correctly encoded.
unsigned long start = millis();
do{
while (ss.available() > 0)
gps.encode(ss.read());
Serial.print("It's here");
// if (gps.location.isUpdated()){
Serial.print("Latitude= ");
Serial.print(gps.location.lat(), 6);
Serial.print(" Longitude= ");
Serial.println(gps.location.lng(), 6);
Serial.print("Raw date DDMMYY = ");
Serial.println(gps.date.value());
Serial.print("Raw time in HHMMSSCC = ");
Serial.println(gps.time.value());
Serial.print("Speed in km/h = ");
Serial.println(gps.speed.kmph());
Serial.print("Altitude in meters = ");
Serial.println(gps.altitude.meters());
Serial.print("HDOP = ");
Serial.println(gps.hdop.value());
//}
}
while(millis() - start < 1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment