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(){

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

  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)

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.

  • is the GPS getting a good view of the sky? Should add some prints to see if you are getting into gpsdump() or just print your lat/lon rather then reassigning it to LAT/LON – Chad G Jun 27 '18 at 23:40
  • @ChadG: I've kept it on a wide window sill with a view. So I guess that should work. Surprisingly, now it's even displaying garbage like ⸮7C⸮wyCCZVa⸮HR-⸮K=LR3⸮(⸮:⸮xk;GqB⸮9Jb⸮j I added some prints inside the gpsdump(). Nothing happens, so I'm not even sure if it's getting into it. – db18 Jun 28 '18 at 2:47
  • Can you update the code and provide the output – Chad G Jun 28 '18 at 4:02
  • @ChadG: I updated the code and results. – db18 Jun 28 '18 at 16:34
  • Actually update the code in the question, its to hard to go back and forth between your original code and the comment. Did you ever try the GPS baud rate of 4800? – Chad G Jun 28 '18 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.