├── .gitattributes └── Code └── Code.ino /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Code/Code.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | TinyGPSPlus gps; 5 | #define gpsSerial Serial2 6 | 7 | 8 | void setup() { 9 | Serial.begin(115200); 10 | gpsSerial.begin(9600, SERIAL_8N1, 16, 17); 11 | Serial.println("Waiting for GPS fix and satellites..."); 12 | } 13 | 14 | void loop() { 15 | 16 | while (gpsSerial.available() > 0) 17 | if (gps.encode(gpsSerial.read())) 18 | displayLocationInfo(); 19 | 20 | if (millis() > 5000 && gps.charsProcessed() < 10) { 21 | Serial.println(F("No GPS detected: check wiring.")); 22 | while (true); 23 | } 24 | 25 | 26 | delay(1000); 27 | } 28 | 29 | void displayLocationInfo() { 30 | Serial.println(F("-------------------------------------")); 31 | Serial.println("\n Location Info:"); 32 | 33 | Serial.print("Latitude: "); 34 | Serial.print(gps.location.lat(), 6); 35 | Serial.print(" "); 36 | Serial.println(gps.location.rawLat().negative ? "S" : "N"); 37 | 38 | Serial.print("Longitude: "); 39 | Serial.print(gps.location.lng(), 6); 40 | Serial.print(" "); 41 | Serial.println(gps.location.rawLng().negative ? "W" : "E"); 42 | 43 | Serial.print("Fix Quality: "); 44 | Serial.println(gps.location.isValid() ? "Valid" : "Invalid"); 45 | 46 | Serial.print("Satellites: "); 47 | Serial.println(gps.satellites.value()); 48 | 49 | Serial.print("Altitude: "); 50 | Serial.print(gps.altitude.meters()); 51 | Serial.println(" m"); 52 | 53 | Serial.print("Speed: "); 54 | Serial.print(gps.speed.kmph()); 55 | Serial.println(" km/h"); 56 | 57 | Serial.print("Course: "); 58 | Serial.print(gps.course.deg()); 59 | Serial.println("°"); 60 | 61 | Serial.print("Date: "); 62 | if (gps.date.isValid()) { 63 | Serial.printf("%02d/%02d/%04d\n", gps.date.day(), gps.date.month(), gps.date.year()); 64 | } else { 65 | Serial.println("Invalid"); 66 | } 67 | 68 | Serial.print("Time (UTC): "); 69 | if (gps.time.isValid()) { 70 | Serial.printf("%02d:%02d:%02d\n", gps.time.hour(), gps.time.minute(), gps.time.second()); 71 | } else { 72 | Serial.println("Invalid"); 73 | } 74 | 75 | Serial.println(F("-------------------------------------")); 76 | } --------------------------------------------------------------------------------