Closed hiltswaltts closed 6 years ago
What an excellent report! The example data was crucial.
BTW, I would like to suggest a few things:
Count the GPS fixes for an accurate elapsed time, in seconds. The Arduino millis()
clock will drift a little. This could cause the sketch to print once every 3 seconds. The could happen on every interval, or just occasionally, depending on your particular crystal.
Use the fix.valid.xxx
flags instead of caching their values. There is no way in your sketch for the cached valid_date
to be set to false
, even if the GPS device stops reporting a date.
You can save some RAM by using the F macro on double-quoted prints (like "ABC") and single-quote character prints (like ':' instead of ":").
Incorporating all those changes:
#include <NMEAGPS.h>
#include <GPSport.h>
NMEAGPS gps;
gps_fix fix;
uint8_t fixCount;
void setup() {
Serial.begin(115200);
gpsPort.begin(9600);
}
void loop() {
while (gps.available( Serial1 )) {
fix = gps.read();
fixCount++;
if (fixCount >= 2) {
fixCount = 0;
if (fix.valid.date) {
Serial.print(fix.dateTime.month); Serial.print('/'); Serial.print(fix.dateTime.date); Serial.print('/'); Serial.println(fix.dateTime.year);
} else {
Serial.println( F("--/--/--") );
}
if (fix.valid.time) {
Serial.print(fix.dateTime.hours); Serial.print(':'); Serial.print(fix.dateTime.minutes); Serial.print(':'); Serial.println(fix.dateTime.seconds);
} else {
Serial.println( F("--:--:--") );
}
Serial.println();
}
}
}
Thanks for the feedback!
Sorry, I forgot to mention: you need to get the new NMEAGPS.cpp file for the Libraries/NeoGPS/src directory. This is not a new release yet.
This is with a Garmin 18x LVC connected to an Arduino MEGA through hardware serial, using a MAX3232 RS232 to TTL converter. The Garmin's firmware has been updated to the latest version (4.00). I've tired setting the GPS baud rate to both 9600 and 38400 with no effect.
The Garmin is sending the following sentences in this order, as reported by NMEAOrder.INO :
RMC GGA GSA GSV GSV GSV GLL
These are the only sentences are enabled in NMEAGPS_cfg.h, and LAST_SENTENCE_IN_INTERVAL has been set to NMEA_GLL, and verified correct by NMEAorder.ino. It is not possible to enable $GPZDA sentences on the Garmin 18x.
(I started with GLL disabled in both the Garmin's settings and in NMEAGPS_cfg.h, with GSV being the LAST_SENTENCE_IN_INTERVAL, but I enabled it to see if that would fix the problem, since GLL also includes the UTC time of fix, and I haven't bothered to disable it yet.)
NMEA.INO returns:
The following program:
Returns:
Both Adadruit's GPS_HardwareSerial_Parsing.ino and TinyGPS++'s KitchenSink.ino (slightly modified to use hardware serial) are able to parse the time and date correctly, without making any changes to my hardware or the Garmin's internal settings.
Adadruit's GPS_HardwareSerial_Parsing.ino returns: