Go Down

Topic: GPS 6MV2 only displaying *****  (Read 212 times) previous topic - next topic

Supermuskox

Hey everyone,

I've been trying to get the GPS6MV2 to work for quite a while now, but nothing seems to have worked. I was hoping you guys could help me get it to work. I'm using SoftwareSerial on pin 3 and 4. ANd I'm using the TinyGPS Library, and I'm running the FullExample code.

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


Running the code only gives me stars, but the chars received does continue to rise. Does anyone have any idea what I can do to make it work again?

Image of Serial Monitor



My first post on the forums btw, hope I'm doing this right...
Anyway thanks for reading!

-dev

Congrats on figuring out the code tags to display your sketch properly.  This seems to be a real puzzler for many new members.

Because the character count is increasing but no sentences are being detected, you probably have the wrong baud rate.  The ublox devices default to 9600, not 4800.

I would like to suggest my NeoGPS library.  It is smaller, faster, more accurate and more reliable than all other GPS libraries.  If you'd like to try it, it's available from the Arduino IDE Library Manager, under the menu Sketch -> Include Library -> Manage Libraries.

It also has many examples that are structured correctly.  All other libraries' examples, including this one, are very fragile.  Modifying them will usually break them.  For example, the FullExample sketch prints too much information for a Serial baud rate of 9600.  It is 115200 in this example -- modyifing the Serial baud rate to 9600 would break it.

The corresponding example in NeoGPS is called Tabular, and using it saves about 300 bytes of RAM.  Other NeoGPS examples output a CSV format that is more compact (to avoid printing too much).  For example, here is some NMEA.ino output:

Code: [Select]
NMEA.INO: started
  fix object size = 31
  gps object size = 84
Looking for GPS device on Serial1

GPS quiet time is assumed to begin after a RMC sentence is received.
  You should confirm this with NMEAorder.ino

Status,UTC Date/Time,Lat,Lon,Hdg,Spd,Alt,Sats,Rx ok,Rx err,Rx chars,
3,2016-05-24 01:21:29.00,472852332,85652650,,138,,,1,0,66,
3,2016-05-24 01:21:30.00,472852311,85652653,,220,24040,7,9,0,557,
3,2016-05-24 01:21:31.00,472852315,85652647,,449,24080,7,17,0,1048,

These CSV lines are suitable for importing into a spreadsheet.

NeoGPS also includes an example called NMEAdiagnostic.  This sketch can help you figure out the correct baud rate, if 9600 doesn't work for you.

I would also suggest avoiding SoftwareSerial.  This library is very inefficient, because it disables interrupts for long periods of time.  This can interfere with other parts of your sketch or with other libraries.  Here is a description of the alternatives, from best to worst.

BTW, you don't have to post an image of the Serial Monitor.  Instead, select the text in the Serial Monitor window, copy it (ctrl-C) and then paste it (ctrl-V) into your post (it may help to uncheck the "Autoscroll" box in the lower left-hand corner).  Put it in code tags, just like your sketch...

Code: [Select]
... so the copied
     text looks like this:

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
0    9999 ********** *********** **** 02/20/2018 14:10:44 902  ****** ****** ***** ***   ******** ****** ***   273   0         0

Cheers,
/dev
Really, I used to be /dev.  :(

Supermuskox

Hey -dev, thanks for the reply! Using NeoGPS and AltSoftSerial seems to have done the trick. GPS works as supposed and actually gives me Latitude and Longitude! I'll let you know when we stumple onto another questions but for nowe we'll try and figure this out ourselves.

-Supermuskox

Supermuskox

Okay so I've been testing the device and my biggest issue is the inconsistency. Leaving it on takes a while to fix (understandable cause I'm inside), and I can live with that. My biggest issue however is that the GPS 6MV2 doesn't always appear to sync up the clock. U-center will show ??:??:?? where it would normally write the time, and NeoGPS Just writes a 0 at the place of the date and time.

I am using NeoGPS and AltSoftSerial and it works like a charm. Using just AltSoftSerial to send the data to u-center works pretty good as well.

Here are some examples of what is shown to me:

Code: [Select]
??:??:??  $GPVTG,,,,,,,,,N*30
??:??:??  $GPGGA,,,,,,0,00,99.99,,,,,,*48
??:??:??  $GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30
??:??:??  $GPGSV,2,1,08,04,,,22,12,,,19,18,,,22,21,,,22*77
??:??:??  $GPGSV,2,2,08,27,,,24,28,,,19,32,,,23,42,,,27*73
??:??:??  $GPGLL,,,,,,V,N*64
??:??:??  $GPRMC,,V,,,,,,,,,,N*53
??:??:??  $GPVTG,,,,,,,,,N*30
??:??:??  $GPGGA,,,,,,0,00,99.99,,,,,,*48
??:??:??  $GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30
??:??:??  $GPGSV,2,1,06,04,,,34,12,,,18,15,,,24,18,,,22*7E
??:??:??  $GPGSV,2,2,06,21,,,22,32,,,28*77
??:??:??  $GPGLL,,,,,,V,N*64
??:??:??  $GPRMC,,V,,,,,,,,,,N*53
??:??:??  $GPVTG,,,,,,,,,N*30
??:??:??  $GPGGA,,,,,,0,00,99.99,,,,,,*48
??:??:??  $GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30
??:??:??  $GPGSV,2,1,06,04,,,24,12,,,15,16,,,27,17,,,26*79
??:??:??  $GPGSV,2,2,06,18,,,19,32,,,13*7D
??:??:??  $GPGLL,,,,,,V,N*64
??:??:??  $GPRMC,,V,,,,,,,,,,N*53
??:??:??  $GPVTG,,,,,,,,,N*30
??:??:??  $GPGGA,,,,,,0,00,99.99,,,,,,*48
??:??:??  $GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30
??:??:??  $GPGSV,1,1,04,12,,,13,16,,,27,18,,,18,32,,,13*7D
??:??:??  $GPGLL,,,,,,V,N*64


u-center

Code: [Select]
NMEA.INO: started
  fix object size = 31
  gps object size = 92
Looking for GPS device on AltSoftSerial( RX pin 8, TX pin 9 )

GPS quiet time is assumed to begin after a RMC sentence is received.
  You should confirm this with NMEAorder.ino

Status,UTC Date/Time,Lat,Lon,Hdg,Spd,Alt,Sats,micros(),Rx ok,Rx err,Rx chars,
0,,,,,,,,0,1,0,23,
0,,,,,,,0,0,9,0,293,
0,,,,,,,0,0,17,0,563,
0,,,,,,,0,0,25,0,833,
0,,,,,,,0,0,33,0,1111,
0,,,,,,,0,0,41,0,1381,
0,,,,,,,0,0,49,0,1651,
0,,,,,,,0,0,56,0,1895,
0,,,,,,,0,0,63,0,2131,
0,,,,,,,0,0,70,0,2367,
0,,,,,,,0,0,77,0,2603,
0,,,,,,,0,0,84,0,2823,
0,,,,,,,0,0,91,0,3043,
0,,,,,,,0,0,97,0,3237,
0,,,,,,,0,0,105,0,3507,
0,,,,,,,0,0,113,0,3793,
0,,,,,,,0,0,121,0,4087,
0,,,,,,,0,0,129,0,4381,
0,,,,,,,0,0,137,0,4667,
0,,,,,,,0,0,145,0,4961,
0,,,,,,,0,0,153,0,5247,
0,,,,,,,0,0,161,0,5525,
0,,,,,,,0,0,169,0,5811,
0,,,,,,,0,0,177,0,6097,
0,,,,,,,0,0,185,0,6375,
0,,,,,,,0,0,193,0,6661,
0,,,,,,,0,0,201,0,6955,
0,,,,,,,0,0,209,0,7249,
0,,,,,,,0,0,217,0,7543,
0,,,,,,,0,0,224,0,7787,
0,,,,,,,0,0,231,0,8023,
0,,,,,,,0,0,238,0,8251,
0,,,,,,,0,0,245,0,8471,
0,,,,,,,0,0,252,0,8699,
0,,,,,,,0,0,259,0,8927,
0,,,,,,,0,0,266,0,9163,
0,,,,,,,0,0,273,0,9399,
0,,,,,,,0,0,280,0,9627,
0,,,,,,,0,0,287,0,9863,
0,,,,,,,0,0,294,0,10083,
0,,,,,,,0,0,301,0,10319,
0,,,,,,,0,0,308,0,10555,
0,,,,,,,0,0,315,0,10791,
0,,,,,,,0,0,322,0,11035,
0,,,,,,,0,0,330,0,11305,
0,,,,,,,0,0,337,0,11549,
0,,,,,,,0,0,345,0,11819,
0,,,,,,,0,0,353,0,12089,
0,,,,,,,0,0,361,0,12359,
0,,,,,,,0,0,368,0,12603,
0,,,,,,,0,0,375,0,12847,
0,,,,,,,0,0,381,0,13033,
0,,,,,,,0,0,387,0,13219,
0,,,,,,,0,0,393,0,13405,
0,,,,,,,0,0,399,0,13591,
0,,,,,,,0,0,405,0,13761,
0,,,,,,,0,0,411,0,13931,
0,,,,,,,0,0,417,0,14101,
0,,,,,,,0,0,423,0,14271,
0,,,,,,,0,0,429,0,14441,
0,,,,,,,0,0,435,0,14611,
0,,,,,,,0,0,440,0,14755,
0,,,,,,,0,0,445,0,14899,
0,,,,,,,0,0,451,0,15069,
0,,,,,,,0,0,457,0,15239,
0,,,,,,,0,0,463,0,15417,
0,,,,,,,0,0,469,0,15595,
0,,,,,,,0,0,475,0,15765,
0,,,,,,,0,0,481,0,15959,
0,,,,,,,0,0,488,0,16179,
0,,,,,,,0,0,495,0,16407,
0,,,,,,,0,0,502,0,16627,


NMEA example code from NeoGPS library.


What would be the best way to consistently sync up the time here?

Thanks!

-Supermuskox

-dev

Quote
My biggest issue however is that the GPS 6MV2 doesn't always appear to sync up the clock.
From the data you showed, you just do not have good enough satellite reception.  If you are inside, you may only get a good fix (time or time & location) when the satellites are visible through the nearest door or window.  They are constantly moving, and different satellites will be different at different times.

There's nothing else to do except move to a position with better reception.  There are sensitive antennas, but they are very expensive.  Even that may not guarantee a constant fix.

Most GPS modules have an on-board battery.  This should normally help the GPS device "remember" the current time, once it has gotten a good time fix.  If it is too long between fixes, it may intentionally "forget" the current time, because it may have too much error.
Really, I used to be /dev.  :(

Go Up