[go: up one dir, main page]

0% found this document useful (0 votes)
35 views1 page

GPS Module Test Code

This document contains an Arduino sketch that utilizes the TinyGPS++ library to read GPS data from a serial connection. It initializes the GPS module, reads location data, and prints the latitude, longitude, altitude, speed, and number of satellites to the Serial Monitor. The code continuously updates and displays this information as long as GPS data is available.

Uploaded by

kaishwarya978
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views1 page

GPS Module Test Code

This document contains an Arduino sketch that utilizes the TinyGPS++ library to read GPS data from a serial connection. It initializes the GPS module, reads location data, and prints the latitude, longitude, altitude, speed, and number of satellites to the Serial Monitor. The code continuously updates and displays this information as long as GPS data is available.

Uploaded by

kaishwarya978
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <SoftwareSerial.

h>
#include <TinyGPS++.h>

static const int RXPin = 12, TXPin = 13;


static const uint32_t GPSBaud = 9600;

SoftwareSerial gpsSerial(RXPin, TXPin);


TinyGPSPlus gps;

void setup() {
Serial.begin(9600);
gpsSerial.begin(GPSBaud);
Serial.println("GPS Test Starting...");
}

void loop() {
while (gpsSerial.available() > 0) {
gps.encode(gpsSerial.read());

if (gps.location.isUpdated()) {
// Determine N/S and E/W
char ns = (gps.location.lat() >= 0) ? 'N' : 'S';
char ew = (gps.location.lng() >= 0) ? 'E' : 'W';

// Display formatted location


Serial.print("Latitude: ");
Serial.print(abs(gps.location.lat()), 6);
Serial.print("° ");
Serial.println(ns);

Serial.print("Longitude: ");
Serial.print(abs(gps.location.lng()), 6);
Serial.print("° ");
Serial.println(ew);

Serial.print("Altitude: ");
Serial.print(gps.altitude.meters());
Serial.println(" meters");

Serial.print("Speed: ");
Serial.print(gps.speed.kmph());
Serial.println(" km/h");

Serial.print("Satellites: ");
Serial.println(gps.satellites.value());

Serial.println("----------------------");
}
}
}

You might also like