TinyGPSPlus update frequency

I want to edit the library so that the update frequency is changed without changing baud rate. This is my 1st ever programming but I think I'll only have to change an integer value to get it done.

What do you mean?

The "standard" GPS devices like you use that library for continually spew data out over serial when powered. You don't get to tell it how fast to send the data. You just have to keep listening and see if anything changes.

It's also okay to allow TinyGPS to continuously decode data. You aren't forced to use the results continuously, you can read them any time you like.

Also, it is possible to configure some GPS units to send fewer types of NMEA sentences. However, typically that is not a problem and you can just ignore what you don't need, as mentioned above.

The “standard” GPS devices like you use that library for continually spew data out over serial when powered. You don’t get to tell it how fast to send the data. You just have to keep listening and see if anything changes.

Actually, most new GPS devices allow you to set the update rate. 5Hz and 10Hz are the typical limits.

I want to edit the library so that the update frequency is changed…

The update frequency is not in the library. You set the update frequency by sending a special command string to the GPS device. Then the GPS device starts reporting at that rate, instead of the default 1Hz. But…

… without changing baud rate.

You probably have to change the baud rate. For example, at 9600 baud, each character takes ~1ms to be sent from the GPS device. The GPRMC sentence contains ~80 characters. To send one GPRMC sentence, it takes about 84ms. If the update rate is 10Hz, then there are 100ms in each interval, and that’s all the time you get to send the sentence.

Most GPS devices will send more than one sentence per update. GPGGA and GPRMC are the most common, but it’s not unusual to see GPGSA, GPGST, or even GPGSV (actually 3 or 4 sentences). This means there could be 5 or 6 sentences per update interval. Again, if each sentence is ~80 characters long, the total transmission time for all that data at 9600 would be 5 * 80 * 1.04 = 416ms. It won’t fit in 100ms.

If you turn off all sentences but 1, you might get the GPS device to change the update interval without changing the speed. Some devices just require it; you don’t really have a choice. Read the spec to be sure. Here’s a table you can use to see which sentences you really need.

BTW, if you’re looking for a fast GPS library, you should check out my NeoGPS library. It’s 2x faster and uses much less RAM.

Cheers,
/dev

Did you want to increase or decrease the update frequency vs. 1Hz?

@Tesla I want to get only 1 update per second instead of 6. @DrAzzy My GPS module sends the same data at a 'moment' 6 times. I want to receive it 1 time. Help!

uttaran: @Tesla I want to get only 1 update per second instead of 6. @DrAzzy My GPS module sends the same data at a 'moment' 6 times. I want to receive it 1 time. Help!

Actually, your GPS module is sending 6 sentences per second. One disadvantage of TinyGPSPlus is that it doesn't tell you which sentences are part of the once-a-second "GPS update" (aka "update interval" or "update rate"). The TinyGPS++ encode function returns true after each sentence, so you see 6 sentences per second.

If you look at this table, you can see the sentence types (across the top), and what fields they contain (down the side). Your GPS device is probably sending a GGA sentence, an RMC sentence and 4 other sentences. Different brands will send different sentences.

You could wait for the time to be updated, but there are several other problems you will run into later. I really suggest trying NeoGPS. I wrote it to solve this exact problem.

If you follow the Installation instructions, NMEA.ino should work very well for you, and you will only get one update per second. There is also a diagnostic program if NMEA.ino doesn't work. And NMEAorder.ino can be used to list what sentences your GPS module sends each second.

And if you have additional questions, be sure to tell us what Arduino and GPS module you're using, and what example program you tried. If you have changed the example program in any way, be sure to insert it in your post with [code]...[/code] tags...

... so it looks like this.

If it's too big to insert (over 9K), attach it as a file to your post.

Cheers, /dev