Skip to content

Instantly share code, notes, and snippets.

@dkrkamesh
Created January 17, 2017 09:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dkrkamesh/6fa0eed051ae258df9280d52406a0d58 to your computer and use it in GitHub Desktop.
Save dkrkamesh/6fa0eed051ae258df9280d52406a0d58 to your computer and use it in GitHub Desktop.
Arduino GPS: Get Latitude and Longitude Coordinates
#include <SoftwareSerial.h>
#include <TinyGPS.h>
TinyGPS gps;
SoftwareSerial serialgps(2,3);
int year;
byte month, day, hour, minute, second, hundredths;
unsigned long chars;
unsigned short sentences, failed_checksum;
void setup()
{
Serial.begin(9600);
serialgps.begin(9600);
Serial.println("==========================");
Serial.println("GPS");
Serial.println("===========================");
}
void loop()
{
while(serialgps.available())
{
int c = serialgps.read();
if(gps.encode(c))
{
float latitude, longitude;
gps.f_get_position(&latitude, &longitude);
Serial.print("Lat/Long: ");
Serial.print(latitude,6);
Serial.print(",");
Serial.println(longitude,6);
Serial.println();
gps.stats(&chars, &sentences, &failed_checksum);
delay(2000);
}
}
}
@danielkp1234
Copy link

@dkrkamesh what module would I need for running this code on Arduino Uno guessing I need a specific addon board

@architbubber
Copy link

There are many gps modules available with Serial communication such as ublock neo-6m or 7 etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment