Go Down

Topic: Problem with GPS Shield Itead Studio v1.1 (Read 1 time) previous topic - next topic

Hi,

i'm new to arduino stuff. I've recently bought this GPS shield and I cannot make it work. First of all the guy that sold me also gave me a PDF manual with specifications saying it works with 38400 baud rate.

I'm using Arduino UNO R2 board and GPS is set to communicate with RX = 4 and TX = 3.

Here is my code (which is a modified example):

Code: [Select]

#include <TinyGPS.h>

#include <SoftwareSerial.h>

#define RXPIN 3
#define TXPIN 4

TinyGPS gps;
SoftwareSerial ss = SoftwareSerial(RXPIN, TXPIN); // Aqui é feito o instanciamento, ou seja, atribuimos a comunicação serial denominada de  ss (poderia ser gps, minhaporta ou qualquer outra palavra) para as portas 3 e 4.

void setup()
{
  Serial.begin(115200); // Aqui é a velocidade de transmissão entre o Arduino e o PC é de 115200 bps.
  Serial.print("Simple TinyGPS library v. "); Serial.println(TinyGPS::library_version()); //só perfumaria...e os devidos //créditos do autor
  Serial.println("by Mikal Hart");
  Serial.println();
  pinMode(RXPIN, INPUT);
  pinMode(TXPIN, OUTPUT);
  ss.begin(9600);
}

void loop() //loop principal. Os comentários do autor ajudam a entender.
{
  bool newData = false;
  unsigned long chars;
  unsigned short sentences, failed;

  // For one second we parse GPS data and report some key values
  for (unsigned long start = millis(); millis() - start < 1000;)
  {
    while (ss.available())
    {
      char c = ss.read();
      Serial.write(c); // uncomment this line if you want to see the GPS data flowing
      if (gps.encode(c)) // Did a new valid sentence come in?
        newData = true;
    }
  }

  if (newData)
  {
    float flat, flon;
    unsigned long age;
    gps.f_get_position(&flat, &flon, &age);
    Serial.print("LAT=");
    Serial.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
    Serial.print(" LON=");
    Serial.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
    Serial.print(" SAT=");
    Serial.print(gps.satellites() == TinyGPS::GPS_INVALID_SATELLITES ? 0 : gps.satellites());
    Serial.print(" PREC=");
    Serial.print(gps.hdop() == TinyGPS::GPS_INVALID_HDOP ? 0 : gps.hdop());
  }
 
  gps.stats(&chars, &sentences, &failed);
  Serial.print(" CHARS=");
  Serial.print(chars);
  Serial.print(" SENTENCES=");
  Serial.print(sentences);
  Serial.print(" CSUM ERR=");
  Serial.println(failed);
}



As you can see, i used 9600 baud rate from GPS to Arduino and 115200 from Arduino to PC. Altough the PDF said 38400, this (9600) was the only configuration that it seems to work. With 4800 and 38400 baud rates i get strange characters in screen. With this sample code the result is as follow:

Simple TinyGPS library v. 12
by Mikal Hart

$GPGGA,235951.074,,,,,0,00,,,M,0.0,M,,0000*5C
$GPGLL,,,,,235951.074,V*12
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,3,1,12,20,00,000,,10,00,000,,31,00,000,,2 CHARS=153 SENTENCES=0 CSUM ERR=0
7,00,000,*7C
$GPGSV,3,2,12,19,00,000,,07,00,000,,04,00,000,,24,00,000,*76
$GPGSV,3,3,12,16,00,000,,28,00,000,,26,00,000,,29,00,000,*78
$GPRMC,235951.074,V,,,,,,,281006,,*28
$GPVTG,,T,,M,,N,,K*4E
$GPGGA,235952.067,,,,,0,00,,,M,0.0,M,,0000*5D
$GPGLL,,,,,235952.067,V*13
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,235952.067,V,,,,,,,281006,,*29
$GPVTG,,T,,M,,N,,K* CHARS=516 SENTENCES=0 CSUM ERR=0
4E
$GPGGA,235953.067,,,,,0,00,,,M,0.0,M,,0000*5C
$GPGLL,,,,,235953.067,V*12
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,235953.067,V,,,,,,,281006,,*28
$GPVTG,,T,,M,,N,,K*4E CHARS=685 SENTENCES=0 CSUM ERR=0

No matter how much time it runs, it  never gives me a good result.

The GPS shield came with the square antenna and it is correctly connected to it. Could this be a serial communication problem (once i heard that with arduino UNO the GPS shield only worked in pins 0 and 1 (used to exchange messages with PC))?

As it is receiving correct characters I imagine that is not an communication issue. Does anyone have any suggestion?

Thanks

michinyon

That looks pretty normal for GPS communications to me.

What is probably happening,  is that you are doing this indoors  and the GPS is not getting
adequate signal from the sky.

A lot of GPS chips,  including mine,  often take 20 minutes to start up,  if it all.  Even
outside,  it usually takes 6 or 7 minutes.

You can reduce this time on some GPS chips if you provide a backup battery which enables
it to remember the previous state,  which makes the startup process faster.

What you are seeing there,  are the standard GPS text strings,  with a lot of the fields
missing because it hasn't actually been able to calculate them yet.

So advice:

Take it outside
Let it run for 6 or 7 minutes,  at least,  to generate a fix.


Thanks, it works perfectly! It did not take so long but i must use it oustide anyway to catch a signal.

Hello,

I am using Arduino UNO R3 and ITEAD GPS Shield.. I am using it in the following configuration
if i put tx and rx jumpers on column 0 and 1, i get only asterisks.

But if I change the the above config by putting tx and rx jumpers on column 1 and column 0, I am getting the gps data.. but only if i press the reset button every time i need the data.. Apart from the jumper connections is there any other connections I should take care of?


Code: [Select]
#include <TinyGPS.h>

TinyGPS gps;

static void gpsdump(TinyGPS &gps);
static bool feedgps();
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);
 
  Serial.print("Testing TinyGPS library v. "); Serial.println(TinyGPS::library_version());
  Serial.println("by Mikal Hart");
  Serial.println();
  Serial.print("Sizeof(gpsobject) = "); Serial.println(sizeof(TinyGPS));
  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("--------------------------------------------------------------------------------------------------------------------------------------");
}

void loop()
{
  bool newdata = false;
  unsigned long start = millis();
 
  // Every second we print an update
  while (millis() - start < 1000)
  {
    if (feedgps())
      newdata = true;
  }
 
  gpsdump(gps);
}

static void gpsdump(TinyGPS &gps)
{
  float flat, flon;
  unsigned long age, date, time, chars = 0;
  unsigned short sentences = 0, failed = 0;
  static const float 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, 9, 5);
  print_float(flon, TinyGPS::GPS_INVALID_F_ANGLE, 10, 5);
  print_int(age, TinyGPS::GPS_INVALID_AGE, 5);

  print_date(gps);

  print_float(gps.f_altitude(), TinyGPS::GPS_INVALID_F_ALTITUDE, 8, 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 ? 0UL : (unsigned long)TinyGPS::distance_between(flat, flon, LONDON_LAT, LONDON_LON) / 1000, 0xFFFFFFFF, 9);
  print_float(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : TinyGPS::course_to(flat, flon, 51.508131, -0.128002), 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();
}

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

static void print_float(float val, float invalid, int len, int prec)
{
  char sz[32];
  if (val == invalid)
  {
    strcpy(sz, "*******");
    sz[len] = 0;
        if (len > 0)
          sz[len-1] = ' ';
    for (int i=7; i<len; ++i)
        sz[i] = ' ';
    Serial.print(sz);
  }
  else
  {
    Serial.print(val, prec);
    int vi = abs((int)val);
    int flen = prec + (val < 0.0 ? 2 : 1);
    flen += vi >= 1000 ? 4 : vi >= 100 ? 3 : vi >= 10 ? 2 : 1;
    for (int i=flen; i<len; ++i)
      Serial.print(" ");
  }
  feedgps();
}

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

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] : ' ');
  feedgps();
}

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


Need some urgent help..Would really appreciate the help!

PaulS

Code: [Select]
  Serial.print("Testing TinyGPS library v. "); Serial.println(TinyGPS::library_version());
  Serial.println("by Mikal Hart");
  Serial.println();
  Serial.print("Sizeof(gpsobject) = "); Serial.println(sizeof(TinyGPS));
  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("--------------------------------------------------------------------------------------------------------------------------------------");

That's a LOT of SRAM being consumed (unnecessarily) there. The F() macro would be useful.


michinyon

One of my gps modules is idiotically labelled with the tx and rx pins swapped.

So you connect the tx to the tx  and the rx to the rx.

Instead of the tx to the rx and the rx to the tx which you normally do.

Is that the problem you have ?

Go Up