Ublox Neo6MV2 GPS data problem

Hi all,

I have a question. I am using Ublox Neo 6MV2 GPS and connected to Mega 2560 on TX1 and RX1.

I am using an example code to read data which is from TinyGPS+ library

#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 = 19, TXpin = 18;
static const uint32_t GPSBaud = 9600;

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

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

and getting output on serial as;

FullExample.ino
An extensive example of many interesting TinyGPS++ features
Testing TinyGPS++ library v. 0.92
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

**** **** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 0 0 0
No GPS data received: check wiring
**** **** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 0 0 0
No GPS data received: check wiring
**** **** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 0 0 0

I made a voltage divider on TX pin of arduino to GPS RX pin because of 3.3V of GPS input.

Could you help me please about this situation?

Thanks everybody for helping. :slight_smile:

You lost some on this line

static const int RXPin = 19n = 18;

sorry for that, it is my mistake to copy from ide to forum. It is written on code as TXpin I am editing the post. Thanks

Maby because you using softserial, on the hardserial(1) pins of the mega If you wanna use softserial, change to some other pins

What you mean exactly? Sorry, I couldn't understand.

Could you please explain with more detail?

Thanks

What i mean is that you using the softserial libary in your sketsh, The pins you use now 19,18 are the pins of the hardware serial port, maby this will give a confict, So changing to for example pin 20,21 can rule that out.

If you want to check out the Ublox, connect it to pin 0 and 1 load a empty sketch

void setup(){} void loop(){}

and monitor on the arduino ide Serieel Monitor the NEMA lines from the UBLOX. Download u-center from u-blox.com for a nice view.

From ublox tx to mega rx, i dont thing you need the level switcher Hope this will help you futher.

If you are using a Mega, you have multiple serial ports.

Write a very simple program to simply copy the output of the GPS device to the serial monitor on your computer. Be aware that different GPS modules have different default baudrates, you may need to try several.

void setup()
{
    Serial.begin(9600);
    Serial1.begin(9600);
}

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