Trouble getting speed from NeoGPS and u-blox SAM-M8Q

Hi All,

So I have a SAM-M8Q GPS unit from u-blox and am trying to interface with what is essentially an Arduino Mega (it's an offshoot board that has incorporated RF module). I found out that TinyGPS++ can not parse $GN (I was using TinyGPS library with my old GPS unit that did not do $GN) so I have switched to NeoGPS but I am not having much luck.

First, if I print directly to the serial monitor, it appears that I am getting valid input and the GPS unit is getting a lock. See below for an example of serial monitor reading:

$GNGSA,A,3,15,21,13,29,,,,,,,,,4.28,1.88,3.84*12
$GNGSA,A,3,87,,,,,,,,,,,,4.28,1.88,3.84*13
$GPGSV,2,1,05,10,04,267,,13,57,065,34,15,76,174,39,21,52,305,32*73
$GPGSV,2,2,05,29,33,210,23*45
$GLGSV,1,1,03,65,58,274,,66,04,244,,87,61,196,39*53
$GNGLL,4339.36766,N,07933.28536,W,013307.00,A,A*68
$GNRMC,013308.00,A,4339.36753,N,07933.28540,W,0.050,,060718,,,A*74
$GNVTG,,T,,M,0.050,N,0.093,K,A*32
$GNGGA,013308.00,4339.36753,N,07933.28540,W,1,05,1.88,136.6,M,-36.0,M,,*7B
$GNGSA,A,3,15,21,13,29,,,,,,,,,4.27,1.88,3.84*1D
$GNGSA,A,3,87,,,,,,,,,,,,4.27,1.88,3.84*1C
$GPGSV,2,1,05,10,04,267,,13,57,065,34,15,76,174,39,21,52,305,31*70
$GPGSV,2,2,05,29,33,210,22*44
$GLGSV,1,1,03,65,58,274,,66,04,244,,87,61,196,39*53
$GNGLL,4339.36753,N,07933.28540,W,013308.00,A,A*60
$GNRMC,013309.00,A,4339.36743,N,07933.28542,W,0.049,,060718,,,A*7E
$GNVTG,,T,,M,0.049,N,0.091,K,A*38
$GNGGA,013309.00,4339.36743,N,07933.28542,W,1,05,1.88,135.9,M,-36.0,M,,*75
$GNGSA,A,3,15,21,13,29,,,,,,,,,4.27,1.88,3.84*1D
$GNGSA,A,3,87,,,,,,,,,,,,4.27,1.88,3.84*1C
$GPGSV,2,1,05,10,04,267,,13,57,065,34,15,76,174,39,21,52,305,29*79
$GPGSV,2,2,05,29,33,210,22*44
$GLGSV,1,1,03,65,58,274,,66,04,244,,87,61,196,39*53
$GNGLL,4339.36743,N,07933.28542,W,013309.00,A,A*62
$GNRMC,013310.00,A,4339.36737,N,07933.28544,W,0.065,,060718,,,A*7D
$GNVTG,,T,,M,0.065,N,0.120,K,A*3D
$GNGGA,013310.00,4339.36737,N,07933.28544,W,1,05,1.88,135.3,M,-36.0,M,,*72
$GNGSA,A,3,15,21,13,29,,,,,,,,,4.27,1.88,3.84*1D
$GNGSA,A,3,87,,,,,,,,,,,,4.27,1.88,3.84*1C
$GPGSV,2,1,05,10,04,267,,13,57,065,35,15,76,174,39,21,52,305,28*79
$GPGSV,2,2,05,29,33,210,20*46
$GLGSV,1,1,03,65,58,274,,66,04,244,,87,61,196,40*5D
$GNGLL,4339.36737,N,07933.28544,W,013310.00,A,A*6F
$GNRMC,013311.00,A,4339.36736,N,07933.28551,W,0.121,,060718,,,A*78
$GNVTG,,T,,M,0.121,N,0.224,K,A*3B
$GNGGA,013311.00,4339.36736,N,07933.28551,W,1,05,1.87,135.3,M,-36.0,M,,*79
$GNGSA,A,3,15,21,13,29,,,,,,,,,4.27,1.87,3.84*12
$GNGSA,A,3,87,,,,,,,,,,,,4.27,1.87,3.84*13
$GPGSV,2,1,05,10,04,267,,13,57,065,35,15,76,174,41,21,52,305,28*76
$GPGSV,2,2,05,29,33,210,20*46
$GLGSV,1,1,03,65,58,274,,66,04,244,,87,61,196,40*5D
$GNGLL,4339.36736,N,07933.28551,W,013311.00,A,A*6B
$GNRMC,013312.00,A,4339.36742,N,07933.28572,W,0.131,,060718,,,A*78
$GNVTG,,T,,M,0.131,N,0.242,K,A*3A
$GNGGA,013312.00,4339.36742,N,07933.28572,W,1,05,1.87,134.9,M,-36.0,M,,*73
$GNGSA,A,3,15,21,13,29,,,,,,,,,4.27,1.87,3.84*12
$GNGSA,A,3,87,,,,,,,,,,,,4.27,1.87,3.84*13
$GPGSV,2,1,05,10,04,267,,13,57,065,36,15,76,174,39,21,52,305,32*71
$GPGSV,2,2,05,29,33,210,30*47
$GLGSV,1,1,03,65,58,274,,66,04,244,,87,61,196,41*5C
$GNGLL,4339.36742,N,07933.28572,W,013312.00,A,A*6A
$GNRMC,013313.00,A,4339.36738,N,07933.28574,W,0.026,,060718,,,A*75
$GNVTG,,T,,M,0.026,N,0.048,K,A*35
$GNGGA,013313.00,4339.36738,N,07933.28574,W,1,05,1.87,134.6,M,-36.0,M,,*76
$GNGSA,A,3,15,21,13,29,,,,,,,,,4.27,1.87,3.84*12
$GNGSA,A,3,87,,,,,,,,,,,,4.27,1.87,3.84*13
$GPGSV,2,1,05,10,04,267,,13,57,065,32,15,76,174,33,21,52,305,30*7D
$GPGSV,2,2,05,29,33,210,21*47
$GLGSV,1,1,03,65,58,274,24,66,04,244,,87,61,196,37*5B
$GNGLL,4339.36738,N,07933.28574,W,013313.00,A,A*60
$GNRMC,013314.00,A,4339.36733,N,07933.28573,W,0.135,,060718,,,A*7D
$GNVTG,,T,,M,0.135,N,0.250,K,A*3D
$GNGGA,013314.00,4339.36733,N,07933.28573,W,1,05,1.87,134.3,M,-36.0,M,,*78
$GNGSA,A,3,15,21,13,29,,,,,,,,,4.27,1.87,3.84*12
$GNGSA,A,3,87,,,,,,,,,,,,4.27,1.87,3.84*13
$GPGSV,2,1,05,10,04,267,,13,57,065,31,15,76,174,28,21,52,305,30*74
$GPGSV,2,2,05,29,33,210,18*4D
$GLGSV,1,1,03,65,58,274,22,66,04,244,,87,61,196,34*5E
$GNGLL,4339.36733,N,07933.28573,W,013314.00,A,A*6B
$GNRMC,013315.00,A,4339.36732,N,07933.28571,W,0.097,,060718,,,A*76
$GNVTG,,T,,M,0.097,N,0.180,K,A*3A
$GNGGA,013315.00,4339.36732,N,07933.28571,W,1,04,2.62,134.3,M,-36.0,M,,*73
$GNGSA,A,3,15,21,13,,,,,,,,,,11.64,2.62,11.34*1A
$GNGSA,A,3,87,,,,,,,,,,,,11.64,2.62,11.34*10
$GPGSV,2,1,05,10,04,267,,13,57,065,31,15,76,174,29,21,52,305,31*74
$GPGSV,2,2,05,29,33,210,*44
$GLGSV,1,1,03,65,58,274,21,66,04,244,,87,61,196,34*5D
$GNGLL,4339.36732,N,07933.28571,W,013315.00,A,A*69
$GNRMC,013316.00,A,4339.36732,N,07933.28569,W,0.091,,060718,,,A*7A
$GNVTG,,T,,M,0.091,N,0.168,K,A*3A
$GNGGA,013316.00,4339.36732,N,07933.28569,W,1,04,2.62,134.2,M,-36.0,M,,*78
$GNGSA,A,3,15,21,13,,,,,,,,,,11.62,2.62,11.32*1A
$GNGSA,A,3,87,,,,,,,,,,,,11.62,2.62,11.32*10
$GPGSV,2,1,05,10,04,267,,13,57,065,31,15,76,174,28,21,52,305,31*75
$GPGSV,2,2,05,29,33,210,*44
$GLGSV,1,1,03,65,58,274,19,66,04,244,,87,61,196,34*56
$GNGLL,4339.36732,N,07933.28569,W,013316.00,A,A*63
$GNRMC,013317.00,A,4339.36735,N,07933.28572,W,0.082,,060718,,,A*74
$GNVTG,,T,,M,0.082,N,0.153,K,A*30
$GNGGA,013317.00,4339.36735,N,07933.28572,W,1,04,2.62,134.3,M,-36.0,M,,*75
$GNGSA,A,3,15,21,13,,,,,,,,,,11.61,2.62,11.31*1A
$GNGSA,A,3,87,,,,,,,,,,,,11.61,2.62,11.31*10
$GPGSV,2,1,06,10,04,267,,13,57,065,32,15,76,174,28,20,,,27*42
$GPGSV,2,2,06,21,52,305,32,29,33,210,*74
$GLGSV,1,1,03,65,58,274,18,66,04,244,,87,61,196,34*57
$GNGLL,4339.36735,N,07933.28572,W,013317.00,A,A*6F

For my code to print to the speed to the LCD screen, I have taken some snippets of code from -dev in this thread:

https://forum.arduino.cc/index.php?topic=447514.msg3079751#msg3079751

And my code is as follows:

#include <NMEAGPS.h>
#include <NeoSWSerial.h>
#include <LiquidCrystal.h>

NeoSWSerial gpsSerial(1,0); //RX,TX
NMEAGPS gps;
gps_fix fix;


// initialize the library with the numbers of the interface pins
//Pin D16 is connected and was intended to somehow control back lighting but does not seem to be used.
LiquidCrystal lcd(18, 17, 22, 21, 20, 19); /*LCD connections*/
int WARNING_LED = 15;


void displayGPS( gps_fix & fix )
{
  int kmh = 0;

  // Print speed
  lcd.setCursor(0,0);
  if (fix.valid.speed && (fix.spd.whole > 5)) {
    kmh = (fix.spd.whole * 185) / 100;
  }
  lcd.print( kmh );
  lcd.print( F(" km/h      ") );

  if (kmh > 40)
    digitalWrite( WARNING_LED, HIGH );
  else
    digitalWrite( WARNING_LED, LOW );

} // displayGPS


void setup()
{
  gpsSerial.begin(9600);            //Set the GPS baud rate.

  pinMode(WARNING_LED, OUTPUT);  

  lcd.begin(16, 2);               // start the library
  lcd.setCursor(0,0);             // set the LCD cursor   position 
  lcd.print("GPS test");          // print a simple message on the LCD 
  delay(2000);
  lcd.clear();
}

void loop()
{
  while (gps.available( gpsSerial )) {  // if there is data coming from the GPS shield
    fix = gps.read();           // get the complete fix structure
    displayGPS( fix );                  // Show pieces of the fix on the LCD
  }

}

For some reason I am always showing speed @ 0kmh

(I drove around with the module in my car, obviously sitting at my desk it should read 0 or some fluctuation)

Any ideas what I might be doing wrong?

Thank you!

TinyGPS++ produces speed.
Take a loc a the topic "Speedometer using UNO and GPS".
Will that work for Your stuff?

From my understanding, TinyGPS++ only parses $GP lines and won't deal with the $GN ones (which for some reason u-blox units seem to mostly use).

Also, NeoGPS is a lot more efficient according to the person who wrote this library.

doublec4:
I found out that TinyGPS++ can not parse $GN

Any ideas what I might be doing wrong?

You should find that that TinyGPS++ has had $GN support from around the begining of this year.

It was always possible to modify it yourself to read the GNGGA and GNRMC sentences but that change is now included.

And of course its easy enough to send a UBLOX GPS the commands to switch to sending out the GPGGA and GPRMC sentences, no need to modify the library at all.

Switch libraries if you want, but there is no need to.

Interesting. Maybe I have to update my TinyGPS library as I did download it quite a while ago.

Regardless, shouldn't neoGPS be able to parse the incoming data? It looks valid... I copied and pasted one of the lines into an online parser and my location was correct...

If anyone has experience with the neoGPS library and can see something wrong with my code I would appreciate it. In the meantime I will go back to TinyGPS and experiment...

doublec4:
In the meantime I will go back to TinyGPS and experiment...

You need to download the TinyGPS++ from Github.