Created
January 17, 2017 09:33
-
-
Save dkrkamesh/6fa0eed051ae258df9280d52406a0d58 to your computer and use it in GitHub Desktop.
Arduino GPS: Get Latitude and Longitude Coordinates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); | |
} | |
} | |
} |
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
@dkrkamesh what module would I need for running this code on Arduino Uno guessing I need a specific addon board