Go Down

Topic: GPS module issue (Read 468 times) previous topic - next topic

jpwolfe31

I am using a Uno R3 and a gps module (HiLetgo GY-NEO6MV2 Flight Controller NEO-6M APM 2.5 Flight Controller GPS Module with Super Strong Ceramic Antenna) that I purchased on Amazon and the TinyGPSPlus library.  I am running the FullExample sketch included with the library and it appears that I am not able to read any data from the device.  

The output from the serial monitor looks like the attached photo.

I am hoping there is a simple error that someone might be able to point me to.  Any other guidance would be appreciated as well.  

Thanks


srnet

The problem could well be in the code you did not post.

Do not expect many people to go hunting for the library you are using and then locate the example program you are using.

The GPS is outdoors, with a good view of the sky ?
Co-Designer of the worlds smallest (known) operational satellite, $50SAT.
http://www.50dollarsat.info/
http://www.loratracker.uk/

jpwolfe31

Yes, the GPS was outside with a view of the sky.

Here is the FullExample sketch.

Code: [Select]


#include <TinyGPS++.h>
#include <SoftwareSerial.h>
/*
   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(115200);
  ss.begin(GPSBaud);

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

void loop()
{
  static const double LONDON_LAT = 51.508131, LONDON_LON = -0.128002;

  printInt(gps.satellites.value(), gps.satellites.isValid(), 5);
  printFloat(gps.hdop.hdop(), gps.hdop.isValid(), 6, 1);
  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.deg()) : "*** ", 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"));
}

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


Idahowalker

Why are you using software serial and why not use 9600 baud? Is the GPS the only device physically hooked up? Do you get error messages? What is happening that does not fit in with your expectation?

robfocus

#4
Jun 17, 2019, 09:10 pm Last Edit: Jun 17, 2019, 09:15 pm by robfocus
If it isn't printing out "No GPS data received: check wiring" then I think your Arduino is at least receiving data in the format it expects from the GPS module. This is better than one module I bought which only seemed to output binary data instead of the NMEA text format.  If I remember correctly you wouldn't get this far if the baud rate was wrong, but, most of the gps modules seem to default to 9600 so you try switching to that.

The problem is none of the fields are valid which is why it's printout out all the *****

The two modules I've used have a green LED which starts flashing once the unit has located satellites and then you normally start getting valid fields.


jpwolfe31

I knew you guys could help.

The answer was changing the baud rate to 9600!!

Thanks again for your help.

srnet

I knew you guys could help.

The answer was changing the baud rate to 9600!!

Thanks again for your help.
There we go, the problem was in the code you chose not to post.
Co-Designer of the worlds smallest (known) operational satellite, $50SAT.
http://www.50dollarsat.info/
http://www.loratracker.uk/

jpwolfe31

Yes, your feedback was helpful too.  I have learned a newbie lesson.

MarkT

The other lesson to learn is that 9600 baud is the default for GPS receivers (and many many other pieces of equipment) and should be the first baud rate to try.

This thread discusses Arduino baud-rate detectors. https://forum.arduino.cc/index.php?topic=38160.0
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

jpom

#9
Jun 27, 2019, 02:17 pm Last Edit: Jun 27, 2019, 03:52 pm by jpom
It's a pity this query wasn't moved to the more suitable topic "Networking, Protocols and Devices". It isn't suited to "General Electronics". It would have reached a bigger audience of GPS explorers who could both assist and benefit from the problem.

I think the OP's approach to learning a new technology and seeking help when it didn't work as hoped is the right model for getting assistance.

There are ample proven tutorials to follow when exploring a new device. If you duplicate a a tutorial then, all things being equal, there is a good chance it will work. If it doesn't work, others can duplicate your efforts and it becomes a question of finding what elements are not "equal". The OP clearly described the equipment and the sketch.

Mikal's GPS tutorials are well known. There was plenty to learn here besides the fact that the GPS baud rate is device specific. Mikal's sketch delivers lots of diagnostic data -- chars received, sentences received and checksum fails all tell a story. Even all those asterisks have meaning that Mikal intended. There are other ways to test a GPS.

My point here is that the OP has followed a sensible model methodology for exploring a new device that gives the best chance to efficiently resolve issues and also makes it easier for those willing to help.

How often do we see someone post their own code (often complex) and their circuit, and say, "it doesn't work, can someone please fix it?"? You have no idea of their skill level, what they've already done to learn about the new device and to what extent they have achieved success with the device by following proven tutorials before embarking on their own customisations?

jpwolfe31 has succeeded in implementing a good GPS sketch and with his next issue he will be better educated re the basics.

Any constructive thoughts on these words?

Go Up