Skip to content

Instantly share code, notes, and snippets.

@sarasantos
Created May 27, 2020 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sarasantos/7f3061413aca9d9699ca4c8ff928863a to your computer and use it in GitHub Desktop.
Save sarasantos/7f3061413aca9d9699ca4c8ff928863a to your computer and use it in GitHub Desktop.
#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