No date from GPS

Hello everybody.

Recently i purchased Quectel L86 chip for GPS/Glonass, Using Hardware Serial on my Arduino Mega I’m watching serial data, All the things are working correctly but there’s no Date.

I’ve to reset the chip or Remove and Re-insert the RTC battery from my board to get the date, if i unplug and re-connect the Arduino to my computer and checkin serial monitor, again there’s no data for DATE.

I’m attaching a picture of my Serial Monitor, Please have a look.

and here is my code

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

// The TinyGPS++ object
TinyGPSPlus gps;



void setup()
{
  Serial.begin(9600);
  Serial2.begin(9600);


  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 (Serial2.available())
      gps.encode(Serial2.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);
}

Thank you very much

Image embedded for our convenience:

5628b6c7026d6ada30ec3f8a6fe92cf325fc34e9.png

Technique described here. Next time, just select the text, copy it, then paste it into a code block.

No checksum errors are reported, so the GPS characters are being sent and received correctly. Have you tried the simple echo test?

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

void loop()
{
  while (Serial2.available())
    Serial.write( Serial2.read() );
}

It should spit sentences out that look like this:

    $GPRMC,013732.000,A,3150.7238,N,11711.7278,E,0.00,0.00,220413,,,A*68

If the 9th field doesn’t have anything in it, the GPS device is not sending the date (22-APR-2013 in the sentence above).

If it does, you might try my GPS library, NeoGPS. The first example, NMEA.ino, prints out date/time as the second field. NeoGPS also has a diagnostics example that might help, and it’s much smaller and faster than other GPS libraries. It will save several hundred bytes of RAM.

BTW, you don’t need SoftwareSerial.

Cheers,
/dev

Thank you for the reply,

@/dev

I just downloaded NeoGPS library and opened NMEA.ino, But how do i configure the code to work on "Serial2" on Arduino Mega, Because I've soldered that on a PCB and cannot de-solder and make new tracks

These instructions are in NMEA.ino:

//-------------------------------------------------------------------------
//  The GPSport.h include file tries to choose a default serial port
//  for the GPS device.  If you know which serial port you want to use,
//  delete this section and declare it here:
//
//    SoftwareSerial gps_port( rxpin, txpin ); // to GPS TX, RX
//          or
//    HardwareSerial & gps_port = Serial2; // an alias
//          or
//    Search and replace all occurrences of "gps_port" with your port's name.

So... delete lines 37 to 63 and declare

    HardwareSerial & gps_port = Serial2;

Instead of that declaration, you could search and replace "gps_port" with "Serial2". Either way. Not both, please.

Cheers,
/dev

Thanks for the reply @/dev

I've tested the Echo code and this is what i got in Arduino Serial Monitor

$GPGSV,3,1,11,26,67,235,17,21,63,042,21,18,57,127,25,16,55,3007,1.16,0.91*19
$GNGSA,A,3,72,87,86,71,,,,,,,,,1.47,1.16,0.91*12
$GPGSV,3,1,11,26,67,235,17,21,63,042,21,18,57,127,25,16,55,3000*18
$GNGSA,A,3,72,87,86,71,,,,,,,,,2.54,1.43,2.10*18
$GPGSV,3,1,11,26,67,235,17,21,63,042,21,18,57,127,26,16,55,300,*70
$GPGSV,3,2,11,39,43,171,,10,35,176,16,27,31,302,,20,28,051,19*70
$GPGSV,3,3,11,29,16,100,13,15,07,079,26,31,04,210,*4A
$GLGSV,3,1,10,87,55,344,24,77,38,254,20,72,37,128,28,71,36,060,30*60
$GLGSV,3,2,10,86,31,065,23,78,25,319,,88,22,292,,76,12,203,*62
$GLGSV,3,3,10,65,06,169,15,70,05,020,*6B
$GNGLL,3942.0753,N,01950.4084,E,155048.000,A,A*42
$GPTXT,01,01,02,ANTSTATUS=OPEN*2B
$GNRMC,155049.000,A,3942.0753,N,01950.4084,E,0.00,210.03,220616,,,A*75
$GPVTG,210.03,T,,M,0.00,N,0.00,K,A*3D
$GPGGA,155049.000,3942.0753,N,01950.4084,E,1,11,1.11,15.9,M,35.0,M,,*52
$GNGSA,A,3,18,20,29,15,21,26,10,,,,,,1.43,1.11,0.90*10
$GNGSA,A,3,72,87,86,71,,,,,,,,,1.43,1.11,0.90*10
$GPGSV,3,1,11,26,67,235,17,21,63,042,21,18,57,127,26,16,55,300,*70
$GPGSV,3,2,11,39,43,171,,10,35,176,16,27,31,302,,20,28,051,19*70
$GPGSV,3,3,11,29,16,100,11,15,07,079,26,31,04,210,*48
$GLGSV,3,1,10,87,55,344,24,77,38,254,20,72,37,128,28,71,36,060,30*60
$GLGSV,3,2,10,86,31,065,23,78,25,319,,88,22,292,,76,12,203,*62
$GLGSV,3,3,10,65,06,169,15,70,05,020,*6B
$GNGLL,3942.0753,N,01950.4084,E,155049.000,A,A*43
$GPTXT,01,01,02,ANTSTATUS=OPEN*2B
$GNRMC,155050.000,A,3942.0753,N,01950.4084,E,0.00,210.03,220616,,,A*7D
$GPVTG,210.03,T,,M,0.00,N,0.00,K,A*3D
$GPGGA,155050.000,3942.0753,N,01950.4084,E,1,11,1.43,15.9,M,35.0,M,,*5D
$GNGSA,A,3,18,20,29,15,21,26,10,,,,,,2.55,1.43,2.10*19
$GNGSA,A,3,72,87,86,71,,,,,,,,,2.55,1.43,2.10*19
$GPGSV,3,1,11,26,67,235,17,21,63,042,21,18,57,127,26,16,55,300,*70
$GPGSV,3,2,11,39,43,171,,10,35,176,16,27,31,302,,20,28,051,19*70
$GPGSV,3,3,11,29,16,100,12,15,07,079,26,31,04,210,*4B
$GLGSV,3,1,10,87,55,344,24,77,38,254,20,72,37,128,28,71,36,060,30*60
$GLGSV,3,2,10,86,31,065,23,78,25,319,,88,22,292,,76,12,203,*62
$GLGSV,3,3,10,65,06,169,14,70,05,020,*6A
$GNGLL,3942.0753,N,01950.4084,E,155050.000,A,A*4B
$GPTXT,01,01,02,ANTSTATUS=OPEN*2B
$GNRMC,155051.000,A,3942.0753,N,01950.4084,E,0.00,210.03,220616,,,A*7C
$GPVTG,210.03,T,,M,0.00,N,0.00,K,A*3D
$GPGGA,155051.000,3942.0753,N,01950.4084,E,1,11,1.11,15.9,M,35.0,M,,*5B
$GNGSA,A,3,18,20,29,15,21,26,10,,,,,,1.43,1.11,0.90*10
$GNGSA,A,3,72,87,86,71,,,,,,,,,1.43,1.11,0.90*10

I don't find $GPRMC in the beginning of any line :frowning: , as you've mentioned

and as you’ve said, I’ve edited the NMEA.ino ‘example code’ by removing the section of “GPSport.h”, and compiled the sketch and got few errors.

code.

#include <Arduino.h>
#include "NMEAGPS.h"

//======================================================================
//  Program: NMEA.ino
//
//  Description:  This program uses the fix-oriented methods available() and
//    read() to handle complete fix structures.
//
//    When the last character of the LAST_SENTENCE_IN_INTERVAL (see NMEAGPS_cfg.h)
//    is decoded, a completed fix structure becomes available and is returned
//    from read().  The new fix is saved the 'fix_data' structure, and can be used
//    anywhere, at any time.
//
//    If no messages are enabled in NMEAGPS_cfg.h, or
//    no 'gps_fix' members are enabled in GPSfix_cfg.h, no information will be
//    parsed, copied or printed.
//
//  Prerequisites:
//     1) Your GPS device has been correctly powered.
//          Be careful when connecting 3.3V devices.
//     2) Your GPS device is correctly connected to an Arduino serial port.
//          See GPSport.h for the default connections.
//     3) You know the default baud rate of your GPS device.
//          If 9600 does not work, use NMEAdiagnostic.ino to
//          scan for the correct baud rate.
//     4) LAST_SENTENCE_IN_INTERVAL is defined to be the sentence that is
//          sent *last* in each update interval (usually once per second).
//          The default is NMEAGPS::NMEA_RMC (see NMEAGPS_cfg.h).  Other
//          programs may need to use the sentence identified by NMEAorder.ino.
//     5) NMEAGPS_RECOGNIZE_ALL is defined in NMEAGPS_cfg.h
//
//  'Serial' is for debug output to the Serial Monitor window.
//
//======================================================================


  HardwareSerial & gps_port = Serial2; // an alias


//------------------------------------------------------------
// For the NeoGPS example programs, "Streamers" is common set
//   of printing and formatting routines for GPS data, in a
//   Comma-Separated Values text format (aka CSV).  The CSV
//   data will be printed to the "debug output device".
// If you don't need these formatters, simply delete this section.

#include "Streamers.h"

//------------------------------------------------------------
// When NeoHWSerial is used, none of the built-in HardwareSerial
//   variables can be used: Serial, Serial1, Serial2 and Serial3
//   *cannot* be used.  Instead, you must use the corresponding
//   NeoSerial, NeoSerial1, NeoSerial2 or NeoSerial3.  This define
//   is used to substitute the appropriate Serial variable in
//   all debug prints below.

#ifdef NeoHWSerial_h
  #define DEBUG_PORT NeoSerial
#else
  #define DEBUG_PORT Serial
#endif

//------------------------------------------------------------
// This object parses received characters
//   into the gps.fix() data structure

static NMEAGPS  gps;

//------------------------------------------------------------
//  Define a set of GPS fix information.  It will
//  hold on to the various pieces as they are received from
//  an RMC sentence.  It can be used anywhere in your sketch.

static gps_fix  fix_data;

//----------------------------------------------------------------
//  This function gets called about once per second, during the GPS
//  quiet time.  It's the best place to do anything that might take
//  a while: print a bunch of things, write to SD, send an SMS, etc.
//
//  By doing the "hard" work during the quiet time, the CPU can get back to
//  reading the GPS chars as they come in, so that no chars are lost.

static void doSomeWork()
{
  // Print all the things!

  trace_all( DEBUG_PORT, gps, fix_data );

} // doSomeWork

//------------------------------------
//  This is the main GPS parsing loop.

static void GPSloop()
{
  while (gps.available( gps_port )) {
    fix_data = gps.read();
    doSomeWork();
  }

} // GPSloop

//--------------------------

void setup()
{
  // Start the normal trace output
  DEBUG_PORT.begin(9600);
  while (!DEBUG_PORT)
    ;

  DEBUG_PORT.print( F("NMEA.INO: started\n") );
  DEBUG_PORT.print( F("  fix object size = ") );
  DEBUG_PORT.println( sizeof(gps.fix()) );
  DEBUG_PORT.print( F("  gps object size = ") );
  DEBUG_PORT.println( sizeof(gps) );
  DEBUG_PORT.println( F("Looking for GPS device on " USING_GPS_PORT) );

  #ifndef NMEAGPS_RECOGNIZE_ALL
    #error You must define NMEAGPS_RECOGNIZE_ALL in NMEAGPS_cfg.h!
  #endif

  #ifdef NMEAGPS_INTERRUPT_PROCESSING
    #error You must *NOT* define NMEAGPS_INTERRUPT_PROCESSING in NMEAGPS_cfg.h!
  #endif

  #if !defined( NMEAGPS_PARSE_GGA ) & !defined( NMEAGPS_PARSE_GLL ) & \
      !defined( NMEAGPS_PARSE_GSA ) & !defined( NMEAGPS_PARSE_GSV ) & \
      !defined( NMEAGPS_PARSE_RMC ) & !defined( NMEAGPS_PARSE_VTG ) & \
      !defined( NMEAGPS_PARSE_ZDA ) & !defined( NMEAGPS_PARSE_GST )

    DEBUG_PORT.println( F("\nWARNING: No NMEA sentences are enabled: no fix data will be displayed.") );

  #else
    if (gps.merging == NMEAGPS::NO_MERGING) {
      DEBUG_PORT.print  ( F("\nWARNING: displaying data from ") );
      DEBUG_PORT.print  ( gps.string_for( LAST_SENTENCE_IN_INTERVAL ) );
      DEBUG_PORT.print  ( F(" sentences ONLY, and only if ") );
      DEBUG_PORT.print  ( gps.string_for( LAST_SENTENCE_IN_INTERVAL ) );
      DEBUG_PORT.println( F(" is enabled.\n"
                            "  Other sentences may be parsed, but their data will not be displayed.") );
    }
  #endif

  DEBUG_PORT.print  ( F("\nGPS quiet time is assumed to begin after a ") );
  DEBUG_PORT.print  ( gps.string_for( LAST_SENTENCE_IN_INTERVAL ) );
  DEBUG_PORT.println( F(" sentence is received.\n"
                        "  You should confirm this with NMEAorder.ino\n") );

  trace_header( DEBUG_PORT );

  DEBUG_PORT.flush();

  // Start the UART for the GPS device
  gps_port.begin( 9600 );
}

//--------------------------

void loop()
{
  GPSloop();
}

error.

Arduino: 1.6.7 (Windows 10), Board: “Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)”

In file included from C:\Users\Mudassir Hussain\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.11\cores\arduino/Arduino.h:28:0,

from sketch\NMEA.ino.cpp:1:

C:\Users\MUDASS~1\AppData\Local\Temp\arduino_18cb9c6fff275cab958fa538afd73172\NMEA.ino: In function ‘void setup()’:

NMEA:119: error: expected ‘)’ before ‘USING_GPS_PORT’

DEBUG_PORT.println( F("Looking for GPS device on " USING_GPS_PORT) );

^

C:\Users\MUDASS~1\AppData\Local\Temp\arduino_18cb9c6fff275cab958fa538afd73172\NMEA.ino:119:23: note: in expansion of macro ‘F’

DEBUG_PORT.println( F("Looking for GPS device on " USING_GPS_PORT) );

^

exit status 1
expected ‘)’ before ‘USING_GPS_PORT’

This report would have more information with
“Show verbose output during compilation”
enabled in File > Preferences.

Thanks

It's a GNRMC instead, and it does have the date information field. NeoGPS is the only library that can parse it. NMEA.ino will show the date.

Just delete the "Looking for..." line.

Cheers,
/dev

@dev/

only ""Looking for GPS device on "" or whole line " DEBUG_PORT.println( F("Looking for GPS device on " USING_GPS_PORT) );" .?

Thanks

The whole line.

NeoGps library is showing me the Date and time, But i cannot implement that library with my existence library, for that purpose I replaced 'GPRMC' to 'GNRMC' in every fields in TinyGps++.h and TinyGPS++.cpp

And it's working good now.

Thanks for your help man

But i cannot implement that library with my existence library

Inconceivable.

I'm sorry, I didn't mean as you're thinking, I cannot implement neogps library because it's very hard for me to do, as my code already finished and my.mind is not capable of taking the burden anymore

Sorry for the misunderstand