I've synced my Uno with the Arduino IDE and I'm using the following code to get the GPS coordinates:
#include <TinyGPS.h>
#include <SoftwareSerial.h>
unsigned long fix_age;
SoftwareSerial GPS(4,3);
TinyGPS gps;
void gpsdump(TinyGPS &gps);
bool feedgps();
void getGPS();
long lat, lon;
float LAT, LON;
void setup(){
GPS.begin(9600);
Serial.begin(9600);
}
void loop(){
long lat, lon;
unsigned long fix_age, time, date, speed, course;
unsigned long chars;
unsigned short sentences, failed_checksum;
// retrieves +/- lat/long in 100000ths of a degree
gps.get_position(&lat, &lon, &fix_age);
// time in hh:mm:ss, date in dd/mm/yy
getGPS();
Serial.print("Latitude : ");
Serial.print(lat/100000,7); //#UPDATED
Serial.print(" :: Longitude : ");
Serial.println(lon/100000,7); //#UPDATED
}
void getGPS(){
bool newdata = false;
unsigned long start = millis();
// Every 1 seconds we print an update
while (millis() - start < 1000)
{
if (feedgps ()){
newdata = true;
}
}
if (newdata)
{
gpsdump(gps);
}
}
bool feedgps(){
while (GPS.available())
{
if (gps.encode(GPS.read()))
return true;
}
return 0;
}
void gpsdump(TinyGPS &gps)
{
//byte month, day, hour, minute, second, hundredths;
gps.get_position(&lat, &lon);
Serial.print("Hello World : "); //#UPDATED (Test)
LAT = lat;
LON = lon;
{
feedgps(); // If we don't feed the gps during this long
}
}
When I compile, it uploads successfully and when I check the serial streams, it displays:
Latitude : 41103 :: Longitude : 41103
But my lat/lon (in the risk of disclosing location) is (38.984898400, -76.957276900)
It doesn't seem to be the same.