TinyGPS wire problem?

Hi, I am sorry if this question has been explained here before, i have been searched for and didnt find anything about my exact problem.

Well.. I am using a GPS shield and. I am usinng port 4 and 4 on gps board.

on monitor, I am getting this results...

CHARS=0 SENTENCES=0 CSUM ERR=0
** No characters received from GPS: check wiring **

any idea?

Tka a lot

cabecinhas:
I am using a GPS shield

Exactly which one? And what model of GPS.

The baud rate on the GPS may not be set to the value you expect. Try other rates.

Hi. After changing the port sequence in SoftwareSerial from SoftwareSerial ss(4, 3); to SoftwareSerial ss(3, 4);

It started to show some information on RX. Its like a incremental number that started from 0 and after some minutes..(about 10) it is about 30021 and still increasing...

After the RX VALUE of 30021 the Fail started increasing as well..

PLease see attachments. Thank you very much. I've spent hours and hours on this and no sucess so far :frowning:

tks

I'd suggest that you leave TinyGPS alone for now; just read from your software serial port and echo it back to the arduino on serial. Until you can see that the GPS is sending sentence data that makes sense, you won't get anything worthwhile from the library.

Hi, Thank you for your asnwer.

Could you give me an example?

Tks for your help.

Compiled, not tested:

#include <SoftwareSerial.h>

SoftwareSerial gps(3, 4);

void setup()
{
Serial.begin(9600);  // Whatever rate you like; better be higher than the gps rate though. Set serial monitor to match
gps.begin(4800); // Or whatever rate the GPS uses
}

void loop()
{
if(gps.available()>0)
  {
  char ch=gps.read();
  Serial.print(ch);  
  }
}

Hi.. First of all, thank you for your answer.

Well.. It seems to work now.

Thats What I am getting on monitor.
$GPRMC,114913.00,A,2307.07787,S,04633.21666,W,0.030,,251013,,,A,

I have put the same port and baud rates on tinyGPs but only asteristiks except in RX coluns that keep increasing numbers

Time to post the code you're using then.

Hi, Wildbill. Tks for your help:

Testing in the simple serial read it is working I can see the coordinates etc.. in monitor..

My Baud rate is 38400 and I'm using 4,3 (rx/tx).

here's the code:

#include <SoftwareSerial.h>

#include <TinyGPS.h>

/* 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(115200);

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(115200);
}

void loop()
{
float flat, flon;
unsigned long age, date, time, chars = 0;
unsigned short sentences = 0, failed = 0;
static const double LONDON_LAT = 51.508131, LONDON_LON = -0.128002;

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);
}

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 = ' ';

  • 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 : ' ');_
    * smartdelay(0);*
    }

Code tags would be helpful - the "#' key in the toolbar adds them, otherwise, as you can see, the forum software munges your code.

Your code is complex - too much so in my view to be at a point where TinyGPS is giving you nothing. I'd make a much simpler sketch that just reads the GPS and gps.encodes the incoming data and outputs a couple of data items. Add all of your other stuff back bit by bit after you have the core working and you'll get a better handle on where the issue is.

Why did you remove the portion of the code that actually gets data from the GPS? How can you expect the code to produce meaningful output without actually reading from the GPS?

Hi.. I'm sorry for the code posted in the last post.

Wel.. Actually I am getting the gps info when I just read the serial and get this:
$GPRMC,132424.00,A,2307.07966,S,04633.21545,W,0.031,,251013,,,A,
Seems to be right by reading serial.

If I send this information to encode, it shows me:
0000000000000000000000000000000000000000000000000000000000000000

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



TinyGPS gps;

SoftwareSerial placaGPS(4, 3);

void setup()
{
Serial.begin(115200);  // Whatever rate you like; better be higher than the gps rate though. Set serial monitor to match
placaGPS.begin(38400); // Or whatever rate the GPS uses
}

void loop()
{
if(placaGPS.available()>0)
  {
  char ch=placaGPS.read();
  Serial.print(gps.encode(ch));
  }
}
  Serial.print(gps.encode(ch));

gps.encode() returns true or false. I can't really see the benefit of printing that.

The TinyGPS library provides some examples. Run one of them AS-IS. What do you get? (From which one?)

Hi, PAuls. Thanks for your help.

I did ran the full example and just changed my Baud rate.. thats all I did.

What I get on Serial monitor is:

Testing TinyGPS library v. 13
by Mikal Hart

Sats HDOP Latitude  Longitude  Fix  Date       Time     Date Alt    Course Speed Card  Distance Course Card  Chars Sentences Checksum
          (deg)     (deg)      Age                      Age  (m)    --- from GPS ----  ---- to London  ----  RX    RX        Fail
-------------------------------------------------------------------------------------------------------------------------------------
**** **** ********* ********** **** ********** ******** **** ****** ****** ***** ***   *******  ****** ***   0     0         0        
**** **** ********* ********** **** ********** ******** **** ****** ****** ***** ***   *******  ****** ***   65    0         1        
**** **** ********* ********** **** ********** ******** **** ****** ****** ***** ***   *******  ****** ***   130   0         1        
**** **** ********* ********** **** ********** ******** **** ****** ****** ***** ***   *******  ****** ***   195   0         1        
**** **** ********* ********** **** ********** ******** **** ****** ****** ***** ***   *******  ****** ***   259   0         1

I can wait for hours and I don't get any info, but the Chars RX

I have just downloaded the example from TinyGPS | Arduiniana?

Tks for the help

The Checksum fail column is saying that the checksum that the library calculated, based on the data received, does not match the checksum that the data says it should compute. Something is causing corruption.

I did ran the full example and just changed my Baud rate.. thats all I did.

Which baud rate? That used to talk to the GPS or that used to talk to the PC?

My Baud rate is 38400 and I'm using 4,3 (rx/tx).

 Serial.begin(115200);
 
  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(115200);

38400 != 115200

Exactly which one? And what model of GPS.

Did I miss your answers to these questions? 38400 is an unusual GPS rate. Typically, they are 4800 or 9600. None I know uses 115200.

Hi! First of all thank you.

Well, I changed my Bald Rate that is 38400 .(see attachment):

I think the gps is communicating with the arduino because if I just run a basic serial read it returns gps info ok, but unformated.
like this:
$GPRMC,135727.00,A,2307.07651,S,04633.21661,W,0.031,,251013,,,A

Sorry about the info I sent you.

THe correct I am using is:

void setup()
{
  Serial.begin(115200);
  
  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(38400);
}

Does the code you are running have:

static bool feedgps()
{
  while (nss.available())
  {
    if (gps.encode(nss.read()))
      return true;
  }
  return false;
}

If so, change that to:
static bool feedgps()
{
while (nss.available())
{
byte gpsChar = nss.read();
Serial.print(gpsChar);
if (gps.encode(gpsChar))
return true;
}
return false;
}

Now, what do you see in the serial monitor?

Hi. No. the code I'm using doesn't have it.

:frowning:

Here's my code:

#include <SoftwareSerial.h>

#include <TinyGPS.h>

/* 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(115200);
  
  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(38400);
}

void loop()
{
  float flat, flon;
  unsigned long age, date, time, chars = 0;
  unsigned short sentences = 0, failed = 0;
  static const double LONDON_LAT = 51.508131, LONDON_LON = -0.128002;
  
  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);
}

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);
}

Here's my code:

Post the snippet from that code where you actually read from the GPS. If it's there, I can't see it.

Hi. I am not sure if I inderstood you, but if you want to see the part where the code get nthe GPS info, its here:

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