GPS Problem

So the main problem is that the GPS is not working but the interesting part is the GPS worked really
well in the past.

I used this sch:

and a old version of TinyGPS, code that i used in the past:

#include <SoftwareSerial.h>
#include <math.h>
#include <TinyGPS.h>

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
/* This sample code demonstrates the normal use of a TinyGPS object.
   It requires the use of SoftwareSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
*/

TinyGPS gps;
SoftwareSerial ss(4, 3);

static void smartdelay(unsigned long ms);
static void print_float(float val, float invalid, int len, int prec);
static void print_int(unsigned long val, unsigned long invalid, int len);
static void print_date(TinyGPS &gps);
static void print_str(const char *str, int len);

void setup()
{
  Serial.begin(9600);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  /*
  Serial.print("Testing TinyGPS library v. "); Serial.println(TinyGPS::library_version());
  Serial.println("by Mikal Hart");
  Serial.println();
  Serial.println("Sats HDOP Latitude  Longitude  Fix  Date       Time     Date Alt    Course Speed Card  Distance Course Card  Chars Sentences Checksum");
  Serial.println("          (deg)     (deg)      Age                      Age  (m)    --- from GPS ----  ---- to London  ----  RX    RX        Fail");
  Serial.println("-------------------------------------------------------------------------------------------------------------------------------------");
*/
  ss.begin(9600);
}
int i;
void loop()
{
  float flat, flon;
  unsigned long age, date, time, chars = 0;
  unsigned short sentences = 0, failed = 0;
  static const double LONDON_LAT = 46.982974, LONDON_LON = 28.862007;
   //46.982974, 28.862007
  gps.satellites();
  gps.hdop();
  gps.f_get_position(&flat, &flon, &age);
  gps;
  gps.f_altitude();
  gps.f_course();
  gps.f_speed_kmph();
  
     // Coordinate between 2 places code: 
   float delLat = abs(flat-LONDON_LAT)*111194.9;
   float delLong = 111194.9*abs(flon-LONDON_LON)*cos(radians((flat+LONDON_LAT)/2));
   float distance = sqrt(pow(delLat,2)+pow(delLong,2));
   // *******
   
  /*
  print_int(gps.satellites(), TinyGPS::GPS_INVALID_SATELLITES, 5);
  print_int(gps.hdop(), TinyGPS::GPS_INVALID_HDOP, 5);
  gps.f_get_position(&flat, &flon, &age);
  print_float(flat, TinyGPS::GPS_INVALID_F_ANGLE, 10, 6);
  print_float(flon, TinyGPS::GPS_INVALID_F_ANGLE, 11, 6);
  print_int(age, TinyGPS::GPS_INVALID_AGE, 5);
  print_date(gps);
  print_float(gps.f_altitude(), TinyGPS::GPS_INVALID_F_ALTITUDE, 7, 2);
  print_float(gps.f_course(), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2);
  print_float(gps.f_speed_kmph(), TinyGPS::GPS_INVALID_F_SPEED, 6, 2);
  print_str(gps.f_course() == TinyGPS::GPS_INVALID_F_ANGLE ? "*** " : TinyGPS::cardinal(gps.f_course()), 6);
  print_int(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0xFFFFFFFF : (unsigned long)TinyGPS::distance_between(flat, flon, LONDON_LAT, LONDON_LON) / 1000, 0xFFFFFFFF, 9);
  print_float(flat == TinyGPS::GPS_INVALID_F_ANGLE ? TinyGPS::GPS_INVALID_F_ANGLE : TinyGPS::course_to(flat, flon, LONDON_LAT, LONDON_LON), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2);
  print_str(flat == TinyGPS::GPS_INVALID_F_ANGLE ? "*** " : TinyGPS::cardinal(TinyGPS::course_to(flat, flon, LONDON_LAT, LONDON_LON)), 6);
*/
  gps.stats(&chars, &sentences, &failed);
//  print_int(chars, 0xFFFFFFFF, 6);
/*  print_int(sentences, 0xFFFFFFFF, 10);
  print_int(failed, 0xFFFFFFFF, 9);*/
  //Serial.println();

  smartdelay(1000);
  
  display.setTextSize(1);
    display.setTextColor(WHITE);
    display.setCursor(0,0);
    display.print("Chars: ");
    display.println(chars);

    
      display.setTextSize(1);
    display.setTextColor(WHITE);
    display.print("Loop: ");
    display.println(i);
    
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.print("Sats: ");
    display.println(gps.satellites());
    
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.print("Lat: ");
    display.println(flat, 6);
    
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.print("Lon: ");
    display.println(flon, 6);
    
     display.setTextSize(1);
    display.setTextColor(WHITE);
    display.print("Alt: ");
    display.println(gps.f_altitude());
    
     display.setTextSize(1);
    display.setTextColor(WHITE);
    display.print("Km/h: ");
    display.println(gps.f_speed_kmph());
    
     display.setTextSize(1);
    display.setTextColor(WHITE);
    display.print("DB2Loc: ");
    display.print(distance,2);
    display.println("m");
    display.display();
    //delay(1000);
    i++;
    display.clearDisplay();
    
}

static void smartdelay(unsigned long ms)
{
  unsigned long start = millis();
  do
  {
    while (ss.available())
      gps.encode(ss.read());
  } while (millis() - start < ms);
}

static void print_float(float val, float invalid, int len, int prec)
{
  if (val == invalid)
  {
    while (len-- > 1)
      Serial.print('*');
    Serial.print(' ');
  }
  else
  {
    Serial.print(val, prec);
    int vi = abs((int)val);
    int flen = prec + (val < 0.0 ? 2 : 1); // . and -
    flen += vi >= 1000 ? 4 : vi >= 100 ? 3 : vi >= 10 ? 2 : 1;
    for (int i=flen; i<len; ++i)
      Serial.print(' ');
  }
  smartdelay(0);
}

static void print_int(unsigned long val, unsigned long invalid, int len)
{
  char sz[32];
  if (val == invalid)
    strcpy(sz, "*******");
  else
    sprintf(sz, "%ld", val);
  sz[len] = 0;
  for (int i=strlen(sz); i<len; ++i)
    sz[i] = ' ';
  if (len > 0)
    sz[len-1] = ' ';
  Serial.print(sz);
  smartdelay(0);
}

static void print_date(TinyGPS &gps)
{
  int year;
  byte month, day, hour, minute, second, hundredths;
  unsigned long age;
  gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age);
  if (age == TinyGPS::GPS_INVALID_AGE)
    Serial.print("********** ******** ");
  else
  {
    char sz[32];
    sprintf(sz, "%02d/%02d/%02d %02d:%02d:%02d ",
        month, day, year, hour, minute, second);
    Serial.print(sz);
  }
  print_int(age, TinyGPS::GPS_INVALID_AGE, 5);
  smartdelay(0);
}

static void print_str(const char *str, int len)
{
  int slen = strlen(str);
  for (int i=0; i<len; ++i)
    Serial.print(i<slen ? str[i] : ' ');
  smartdelay(0);
}

and today I decided to give a try the new version of TinyGPS Plus
so I got out the GPS (no damaged) my OLED (in the old test i used OLED too)

so i connedted the GPS like that :

and uploaded the code, that i tried today:

#include <TinyGPS++.h>
#include <SoftwareSerial.h>

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
/*
   This sample code demonstrates the normal use of a TinyGPS++ (TinyGPSPlus) object.
   It requires the use of SoftwareSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
*/
static const int RXPin = 4, TXPin = 3;
//static const uint32_t GPSBaud = 4800;

// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);

void setup()
{
  Serial.begin(9600);
    display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  ss.begin(9600);

//  Serial.println(F("FullExample.ino"));
//  Serial.println(F("An extensive example of many interesting TinyGPS++ features"));
//  Serial.print(F("Testing TinyGPS++ library v. ")); Serial.println(TinyGPSPlus::libraryVersion());
//  Serial.println(F("by Mikal Hart"));
//  Serial.println();
//  Serial.println(F("Sats HDOP Latitude   Longitude   Fix  Date       Time     Date Alt    Course Speed Card  Distance Course Card  Chars Sentences Checksum"));
//  Serial.println(F("          (deg)      (deg)       Age                      Age  (m)    --- from GPS ----  ---- to London  ----  RX    RX        Fail"));
//  Serial.println(F("---------------------------------------------------------------------------------------------------------------------------------------"));
}
int c;
void loop()
{
  static const double LONDON_LAT = 51.508131, LONDON_LON = -0.128002;

//  printInt(gps.satellites.value(), gps.satellites.isValid(), 5);
//  printInt(gps.hdop.value(), gps.hdop.isValid(), 5);
//  printFloat(gps.location.lat(), gps.location.isValid(), 11, 6);
//  printFloat(gps.location.lng(), gps.location.isValid(), 12, 6);
//  printInt(gps.location.age(), gps.location.isValid(), 5);
//  printDateTime(gps.date, gps.time);
//  printFloat(gps.altitude.meters(), gps.altitude.isValid(), 7, 2);
//  printFloat(gps.course.deg(), gps.course.isValid(), 7, 2);
//  printFloat(gps.speed.kmph(), gps.speed.isValid(), 6, 2);
//  printStr(gps.course.isValid() ? TinyGPSPlus::cardinal(gps.course.value()) : "*** ", 6);

  unsigned long distanceKmToLondon =
    (unsigned long)TinyGPSPlus::distanceBetween(
      gps.location.lat(),
      gps.location.lng(),
      LONDON_LAT, 
      LONDON_LON) / 1000;
//  printInt(distanceKmToLondon, gps.location.isValid(), 9);

  double courseToLondon =
    TinyGPSPlus::courseTo(
      gps.location.lat(),
      gps.location.lng(),
      LONDON_LAT, 
      LONDON_LON);

//  printFloat(courseToLondon, gps.location.isValid(), 7, 2);

  const char *cardinalToLondon = TinyGPSPlus::cardinal(courseToLondon);

//  printStr(gps.location.isValid() ? cardinalToLondon : "*** ", 6);

//  printInt(gps.charsProcessed(), true, 6);
//  printInt(gps.sentencesWithFix(), true, 10);
//  printInt(gps.failedChecksum(), true, 9);
 // Serial.println();
  
  smartDelay(1000);

//  if (millis() > 5000 && gps.charsProcessed() < 10)
//    Serial.println(F("No GPS data received: check wiring"));
    
    
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.setCursor(0,0);
    display.println("Domino60 v0.2 2015");
   // display.println(c);
    
      display.setTextSize(1);
    display.setTextColor(WHITE);
    display.print("Time: ");
    display.print(gps.time.hour());display.print(gps.time.minute());display.println(gps.time.second());
    
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.print("Loop: ");
    display.println(c);
    
        display.setTextSize(1);
    display.setTextColor(WHITE);
    display.print("Stats: ");
    display.println(gps.satellites.value());
    
    
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.print("Lat: ");
    display.println(gps.location.lat());
    
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.print("Long: ");
    display.println(gps.location.lng());
    
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.print("2nd Loc(Km): ");
    display.println(distanceKmToLondon);
    
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.print("2nd Loc(Dir): ");
    display.println(courseToLondon);
    

    display.display();
    c++;
    display.clearDisplay();
}

// This custom version of delay() ensures that the gps object
// is being "fed".
static void smartDelay(unsigned long ms)
{
  unsigned long start = millis();
  do 
  {
    while (ss.available())
      gps.encode(ss.read());
  } while (millis() - start < ms);
}

static void printFloat(float val, bool valid, int len, int prec)
{
  if (!valid)
  {
    while (len-- > 1)
      Serial.print('*');
    Serial.print(' ');
  }
  else
  {
    Serial.print(val, prec);
    int vi = abs((int)val);
    int flen = prec + (val < 0.0 ? 2 : 1); // . and -
    flen += vi >= 1000 ? 4 : vi >= 100 ? 3 : vi >= 10 ? 2 : 1;
    for (int i=flen; i<len; ++i)
      Serial.print(' ');
  }
  smartDelay(0);
}

static void printInt(unsigned long val, bool valid, int len)
{
  char sz[32] = "*****************";
  if (valid)
    sprintf(sz, "%ld", val);
  sz[len] = 0;
  for (int i=strlen(sz); i<len; ++i)
    sz[i] = ' ';
  if (len > 0) 
    sz[len-1] = ' ';
  Serial.print(sz);
  smartDelay(0);
}

static void printDateTime(TinyGPSDate &d, TinyGPSTime &t)
{
  if (!d.isValid())
  {
    Serial.print(F("********** "));
  }
  else
  {
    char sz[32];
    sprintf(sz, "%02d/%02d/%02d ", d.month(), d.day(), d.year());
    Serial.print(sz);
  }
  
  if (!t.isValid())
  {
    Serial.print(F("******** "));
  }
  else
  {
    char sz[32];
    sprintf(sz, "%02d:%02d:%02d ", t.hour(), t.minute(), t.second());
    Serial.print(sz);
  }

  printInt(d.age(), d.isValid(), 5);
  smartDelay(0);
}

static void printStr(const char *str, int len)
{
  int slen = strlen(str);
  for (int i=0; i<len; ++i)
    Serial.print(i<slen ? str[i] : ' ');
  smartDelay(0);
}

The funny part is that after not understanding why the GPS in not working I tried the old style (past) and didn’t worked as well, I done many tests to figure out what’s going on and I have no idea why the GPS is not working.

Any ideas?

That's the setup that I'm using:

|500x343

Sorry for long post but forum don't allow me to post more than limited characters, the code took a lot of place.

Hi, Have you tried the example sketches with the display disconnected to make sure the GPS connection is working.

Tom.... :) Lets check that the GPS hardware is working first.

Have you tried the example sketches with the display disconnected to make sure the GPS connection is working.

Sadly I even if I put it without GPS I can't get data because my PC is far away from any window in the house so i will not get GPS connection/data.

The GPS hardware was fine few weeks ago. Is there any way to verify it like a checking program to see it it's alive ? :D

Write a simple echo program that takes a character from the GPS serial, and writes it to Serial.

That'll tell you a lot.

http://playground.arduino.cc/Tutorials/GPS

I recommended upload example code & paste screen shot of serial out put or quote us serial output data. Based on which we can tell what exact problem his

My GPS module is not Parallax GPS.

but anyway i run the code and connected the pins to tx-tx rx-rx

I open the serial monitor and nothing, after i press reset on the board:

Ô±A,1,,,,,,,,,,,,,,,*1E $GPGSV,2,1,06,21,48,213,,31,35,257,,20ÿ

I press again reset :

Ô±A,1,,,,,,,,,,,,,,,*1E $GPGSV,2,1,06,21,48,213,,31,35,257,,20ÿ&r‚š’b²±,,,,0.00,0.00,030815,,,N*4E $PMTK011,MTKGPS*08 $PMTK010,001*2E $PMTK010,002*2D

and of curse i changed from the code the baund 9600

as i said above im not able to get the GPS to the closest window in the house so that's why I mostly test with a OLED.

connected the pins to tx-tx rx-rx

It's more normal to connect Tx to Rx, and Rx to Tx.

For me your GPS seems fine. You gps is not locked so its getting invalid signal. You just do it open air so quickly catch signal.

If there is cloud it might chance to get signal with low priority. It need atleast 4 satelite lock gps sigñal

It's more normal to connect Tx to Rx, and Rx to Tx.

Yea you are right :D

Time in UTC (HhMmSs): Status (A=OK,V=KO): Latitude: Direction (N/S): Longitude: Direction (E/W): Velocity in knots: Heading in degrees: Date UTC (DdMmAa): Magnetic degrees: (E/W): Mode: $GPRMC,12500

For me your GPS seems fine. You gps is not locked so its getting invalid signal. You just do it open air so quickly catch signal.

Well it worked in the past but right now not sure why it's not, i test on my balcony open air, clear sky, weeks ago i just wated 5 sec and i had locked 4~6 sats but today when i tested i was waitting like 5min and still nothing

Show me the serial output code. On which we can tell what’s happening

Time in UTC (HhMmSs):
Status (A=OK,V=KO):
Latitude:
Direction (N/S):
Longitude:
Direction (E/W):
Velocity in knots:
Heading in degrees:
Date UTC (DdMmAa):
Magnetic degrees:
(E/W):
Mode: $GPRMC,12500

What data comes while connected
Check whether cloud avilble or not
I have software that can enable instant . download trimble studio for GPS.

I found the problem, working with the same code in the past and thinking logical I found that the problem is not the circuit but the actual example code not sure why like that but it's working.

So here we go, In the old TinyGPS we had that declaration of pins :

//GPS device hooked up on pins 4(rx) and 3(tx) SoftwareSerial ss(4, 3);

and the new GPS Tiny Plus :

//GPS device hooked up on pins 4(rx) and 3(tx).
static const int RXPin = 4, TXPin = 3;

as you see from that I hooked up the GPS RX - pin 4 and GPS TX - pin 3;

after testing over and over and changing up the wires again and again, i decided to change the code pins

From (4, 3) to (3, 4) in the old and new TinyGPS and I hooked up the wires GPS RX- pin 4, GPS TX - pin 3 (which in logic way is RX to TX and TX to RX) now you may say didn't you done the same with just changing the cables in the old way, yes I did but changing the code pins somehow worked really well and it's working right now.

This is the new version of TinyGPS ++ |500x277

Do you know the mistery of pins in the code? or the Lib's exeample are wrong pinS? The time is not local time but i will figure out why it's now sawing me the local time.

Is there needed to put any resistors between the pins?
Because i see some king of noise, the arduino / OLED restart itself if i move fast in my hands the breadboard,
could be from the many wires, not sure.

I can see you! :grinning:

You don't have the last digits :D You just can see where I live/country, not my exact location. :D