//code sourced from PabitraKumarGhorai
#include <TinyGPSPlus.h>
#include <SoftwareSerial.h>
const byte gps_RX = 7, gps_TX = 6;// TXPin must be a PWM pin
TinyGPSPlus gps;
SoftwareSerial NEO6M(gps_RX, gps_TX);
void setup() {
Serial.begin(9600);
NEO6M.begin(9600);
}
void loop() {
while (NEO6M.available() > 0) {
if (gps.encode(NEO6M.read()))
displayInfo();
}
if (millis() > 5000 && gps.charsProcessed() < 10) {
Serial.println(F("No GPS detected: check wiring."));
while(true);
}
}
void displayInfo() {
Serial.print(F("Location: "));
if (gps.location.isValid()) {
Serial.print(gps.location.lat(), 6);
Serial.print(F(","));
Serial.print(gps.location.lng(), 6);
}
else {
Serial.print(F("INVALID"));
}
Serial.print(F(" Date "));
if (gps.date.isValid()) {
Serial.print(gps.date.month());
Serial.print(F("/"));
Serial.print(gps.date.day());
Serial.print(F("/"));
Serial.print(gps.date.year());
}
else {
Serial.print(F("INVALID"));
}
Serial.println();
}