Parsing Serial Data Arduino

I have a GPS unit which outputs serial data. I haven't been able to get it to work with tinyGPS, tinyGPS+, or the code here Arduino Playground - GPS. I have been able to manually get data which looks like this using a basic software serial read.

$GNRMC,041505.00,A,3334.77540,N,11715.41038,W,0.044,,280116,,,A7E
$GNVTG,,T,,M,0.044,N,0.082,K,A
37
$GNGGA,041505.00,3334.77540,N,11715.41038,W,1,12,0.82,373.3,M,-32.6,M,,79
$GNGSA,A,3,17,30,07,13,19,28,11,15,08,,,,1.40,0.82,1.14
19
$GNGSA,A,3,77,86,67,87,,,,,,,,,1.40,0.82,1.1417
$GPGSV,4,1,15,01,21,090,08,05,00,249,,07,41,108,28,08,06,039,30
77
$GPGSV,4,2,15,09,05,165,14,11,29,071,16,13,43,299,29,15,10,319,2379
$GPGSV,4,3,15,17,54,193,31,19,42,196,15,28,64,334,18,30,69,073,20
7F
$GPGSV,4,4,15,46,49,145,,48,47,207,,51,50,162,4C
$GLGSV,2,1,08,67,18,249,21,68,16,303,,76,33,080,20,77,51,003,22
6F
$GLGSV,2,2,08,78,16,310,,86,28,035,15,87,63,111,22,88,30,177,*68

I would like to make it so it can recognize a string such as GNRMC and then from that row of data check for a piece of information and then send it back to me. I specifically, for the time being, would like to get the first integer "041505.00" from GNRMC or GNGGA so that I can tell the time using my GPS.

I would appreciate any help as the other parse topics I found only deal with comma part and not the $GNGGA part.

I haven't been able to get it to work with tinyGPS, tinyGPS+, or the code here Arduino Playground - HomePage.

Why not?

I would appreciate any help as the other parse topics I found only deal with comma part and not the $GNGGA part.

What help do you need? IF you have the data as a string, strtok() will tokenize it. The first token is $GNRMC or $GNGGA or the record is useless.

You can use strcmp() to determine if the token is $GNRMC or if the token is $GNGGA. If the token is one of them, parse the rest of the string, just like TinyGPS, TinyGPS++, or any other parsing program does.

If you have the data as a String, shame on you. You then need to search the documentation for the appropriate methods to use to parse the String.

If you don't have the data as a string or a String, you haven't a hope in hell of parsing it, so that is the first thing you need to work on.

I haven't been able to get it to work with tinyGPS, tinyGPS+, or the code here Arduino Playground - HomePage

...or even NeoGPS? It has some diagnostics you can use to help figure out what's wrong. Be sure to read the Install instructions and Troubleshooting tips.

There are lots of things to check, but at least you know the GPS device is working and receiving satellite information.

We'll need more info to help, though:

  • What Arduino and IDE version?
  • What GPS module?
  • What software are you using? Be sure to paste your .INO code between [code]...[/code] tags! See step 7 here.
  • What comes out on the Serial Monitor window? Copy and paste that in another code tag section, too.
  • How is everything hooked up? Attaching a picture, schematic or Fritzing diagram is very helpful.
    Cheers,
    /dev

/dev:
Attaching a picture, schematic or Fritzing diagram is very helpful.
Cheers,
/dev

But a 'Fritzing' should only be the very last resort - a schematic and photo are much better. :slight_smile:

The tinyGPS didn't work for a few reasons. The first reason is that the GPS uses different commands from the standard NMEA. The second issue is that it keeps coming up with checksum errors although it is sending the data over the serial. I tried to use the custom commands for tinyGPS+ to read it but it doesn't work. I will definetely try the strcmp() as well as the neogps. I'll post the code for others to benefit from if I can get it working.

Thanks

The tinyGPS didn't work for a few reasons.

Oh, yes. Your device (ublox 7 or 8?) uses different "talker IDs", like GN instead of GP. NeoGPS allows different talker IDs, while the other libraries reject them. By default, NeoGPS ignores the talker ID and accepts the rest of the message, but you can configure it to save or "approve" the talker IDs as they come in.

BTW, the first NeoGPS example (NMEA.ino) only watches for the RMC message. To parse all the sentences you listed, you'll need to try the NMEAfused.ino example next. Also, you may need to edit the configuration files to enable the extra sentences (NMEAgps_cfg.h) and fields (GPSfix_cfg.h) that you want.

Cheers,
/dev

@/dev

I am using the ublox MAX-M8Q good guess!

The neoGPS library works great, thanks for the link share. Solved the issue. Thanks for all of the help from everyone.