# Help with TinyGPS and LS20031 GPS 5Hz Receiver - RESOLVED

**URL:** <https://forum.arduino.cc/t/help-with-tinygps-and-ls20031-gps-5hz-receiver-resolved/89071>\
**Category:** Networking, Protocols, and Devices\
**Created:** [February 8, 2012, 10:56pm UTC](https://forum.arduino.cc/t/help-with-tinygps-and-ls20031-gps-5hz-receiver-resolved/89071 "2012-02-08T22:56:09Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [February 8, 2012, 10:56pm UTC](https://forum.arduino.cc/t/help-with-tinygps-and-ls20031-gps-5hz-receiver-resolved/89071/1 "2012-02-08T22:56:09Z")

</div>

I have been trying to use the LS20031 GPS 5Hz Receiver with an Arduino Pro Mini (5V, 16 MHz) and the TinyGPS library, but have not been receiving all of the NMEA sentences that the datasheet describes. I'll try to explain as best I can:

- I connected the GPS directly to my computer using an FTDI chip, opened RealTerm, and saw that it was broadcasting 6 of the NMEA sentences with valid data. I could also send some MTK commands (cold restart, change the baudrate, etc.), but when I tried to adjust which NMEA sentences are broadcast, it did not respond. This is not the problem however; the 6 sentences that were originally sent had the information that I need and I can work with it.

- Next, I connected the GPS unit to pins 2 and 3 on the Pro Mini, connected the FTDI chip to the Arduino's serial port, and uploaded the NewSoftSerial example sketch called "NewSoftSerialTest". This sketch basically just sets up the soft serial to use pins 2 and 3, and pipelines whatever data comes through the nss back out through the hardware serial port. With this set up, I opened up RealTerm and only saw 2 NMEA sentences being broadcast.

- Finally, I left the GPS connected as is, and uploaded the TinyGPS example sketch called "test\_with\_gps\_device". This sketch works along with NewSoftSerial, parses the NMEA data, and prints out all of the values in a more readable format. This time, however, nothing gets printed out after the automatic heading printed out by the sketch. I have seen the TinyGPS data displayed almost perfectly _once_ before, but with corrupted data. Most of the time, nothing happens.

I'm certain that the GPS unit is connected properly, but my feeling is that TinyGPS is not getting enough information from the GPS to merrit printing anything out.

I'm thinking it could be a buffer problem...?

Has anyone experienced similar problems?

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [February 10, 2012, 8:01am UTC](https://forum.arduino.cc/t/help-with-tinygps-and-ls20031-gps-5hz-receiver-resolved/89071/2 "2012-02-10T08:01:29Z")

</div>

I'm a complete rookie at this and I am using different hardware, etc (and SoftwareSerial in place of NewSoftSerial) . . .but I was able to replicate your problem and solve by:

changing

```cpp
NewSoftSerial nss(2, 3);

```

to

```cpp
#define nss Serial1

```

Also, be sure GPS baud rates are set correctly (9600 in my case).

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [February 10, 2012, 1:35pm UTC](https://forum.arduino.cc/t/help-with-tinygps-and-ls20031-gps-5hz-receiver-resolved/89071/3 "2012-02-10T13:35:25Z")

</div>

SOLVED

It turns out that it was a buffer problem. I was only getting two sentences because the new software serial buffer was set to 64 bytes (this is done with a #define in the library header file). I changed it to 256, and it works like a charm. I can see all of the information being broadcast regularly when I run the TinyGPS example sketch. I will probably bump it up to 512 for safety.

Thanks for reading!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [February 10, 2012, 5:37pm UTC](https://forum.arduino.cc/t/help-with-tinygps-and-ls20031-gps-5hz-receiver-resolved/89071/4 "2012-02-10T17:37:38Z")

</div>

> I will probably bump it up to 512 for safety.

That's 1/4 of the memory on the Arduino. I wouldn't recommend that.

The need to increase the size of the buffer to hold unread data is an indication that you really need to be reading more often.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [February 15, 2012, 1:47am UTC](https://forum.arduino.cc/t/help-with-tinygps-and-ls20031-gps-5hz-receiver-resolved/89071/5 "2012-02-15T01:47:49Z")

</div>

First of all, I am playing with the Arduino 1.0 IDE.

I have been fighting with my LS20031 GPS for two days and could not get this to work at all. I went over to Mr. Mikal Hart web page {[TinyGPS&nbsp;|&nbsp;Arduiniana](http://arduiniana.org/libraries/tinygps/)} to see if I could learn anything as to what the problem.

I have a suggestion about how to prevent the hassle that I have gone through.  
In stead of the using the following (from the example "test\_with\_gps\_device" inside of TinyGPS) \>\>

```arduino
/* This sample code demonstrates the normal use of a TinyGPS object.
   It requires the use of SoftwareSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 3(rx) and 4(tx).
*/

TinyGPS gps;
SoftwareSerial nss(3, 4);

```

You might want to try \>\>

```arduino
#define RXPIN 3 // From the GPS to the Arduino - <edit> I corrected this.
#define TXPIN 4 

/* This sample code demonstrates the normal use of a TinyGPS object.
   It requires the use of SoftwareSerial, and assumes that you have a
   4800-baud (the LS20031 is set up for 57600-baud) serial GPS device hooked up on pins 4(tx) and 3(rx).
   
  The Circuit:
   Pin assignments for the LS20031 GPS: 
   • GPS Pin 5 (left-most when viewed from above) : No connection (or ground)
   • GPS Pin 4 : to Arduino ground (GND) pin
   • GPS Pin 3 : to Arduino pin 3
   • GPS Pin 2 : No connection
   • GPS Pin 1 (right-most when viewed from above) : to Arduino 3.3V pin
*/

TinyGPS gps;
SoftwareSerial nss(TXPIN, RXPIN);

```

I know this is just Nuances in coding. But the problem I had was I had the TX, RX wired backwards. When I went to Mr. Mikal Hart web page, he used the #define statements for naming his pins and I ported that into the TinyGPS example code, then I realized I had the pins hooked up backwards. That little extra naming clued me that I had those pins wired in backwards. I know the old timers around here will roll their eyes at this, but it just might help a newbie out if using #define to name pins is pushed more and add some text as to why it's named that way.  
And for those newbies out there, as far as I understand, you can sign any pin with the SoftwareSerial using the Arduino 1.0 IDE for the RX and the TX.

As for the buffer- I change my buffer size by adding this to the SoftwareSerial.h file \>\>

```arduino
...
/ ******************************************************************************
* Definitions
****************************************************************************** /

//#define _SS_MAX_RX_BUFF 64 // RX buffer size -- Old Value is 64
#define _SS_MAX_RX_BUFF 128 // RX buffer size for TinyGPS
//#define _SS_MAX_RX_BUFF 256 // RX buffer size for TinyGPS

#ifndef GCC_VERSION
...

```

I just un-remarked which one I was using, and made a note of the old value in case I needed to undo it.  
As you can see I am using the 128 buffer, and from what I can tell TinyGPS is working fine. The 64 buffer size cause the TinyGPS todo nothing.

(That does not mean SoftwareSerial is passing TinyGPS all the correct information- I am having major problems with SoftwareSerial sending garbage to TinyGPS. For the Record I get supper clean GPS 'code' directly from the LS20031 GPS (using Sparkfuns LS20031 GPS Assembly Guide Tutorials) , but SoftwareSerial is adding ton of characters that are not part of the normal GPS 'code'.)

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [February 15, 2012, 1:14pm UTC](https://forum.arduino.cc/t/help-with-tinygps-and-ls20031-gps-5hz-receiver-resolved/89071/6 "2012-02-15T13:14:19Z")

</div>

I agree that the RX vs TX pin usage could be clearer. But, I disagree with adding comments defining how to connect your specific GPS to the Arduino to the example. Someone else with a different GPS or different baud rate might then struggle because they followed your instructions which weren't valid for their GPS.

The buffer size of 64 really should be sufficient. You have yet to show all of your code, so we have no idea why you aren't reading the GPS data fast enough to prevent buffer overflow. Changing your program to read the data more often would let you get away with a smaller buffer.

> I am having major problems with SoftwareSerial sending garbage to TinyGPS.

See above. It could possibly be a problem with your code.

> For the Record I get supper clean GPS 'code' directly from the LS20031 GPS (using Sparkfuns LS20031 GPS Assembly Guide Tutorials)

A link to the code would be useful.

> but SoftwareSerial is adding ton of characters that are not part of the normal GPS 'code'.

I think that this is unlikely. SoftwareSerial is not making up data.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [March 6, 2012, 2:57am UTC](https://forum.arduino.cc/t/help-with-tinygps-and-ls20031-gps-5hz-receiver-resolved/89071/7 "2012-03-06T02:57:15Z")

</div>

Paul  
This is what our GPS Receiver looks like \>\> ![](https://europe1.discourse-cdn.com/arduino/original/4X/a/d/e/ade8522d6efcc947200f2aa6464dd4d17f5c07fd.jpeg)

And Sparkfun's Description of the unit can be found here \>\>[http://www.sparkfun.com/products/8975](http://www.sparkfun.com/products/8975)

The code we are talking about is the example that you can find on Mikal Hart web site for TinyGPS which you can find here \>\> [TinyGPS&nbsp;|&nbsp;Arduiniana](http://arduiniana.org/libraries/tinygps/)

Sparkfun's tutorial on the LS20031 GPS receiver can be found here \>\> [http://www.sparkfun.com/tutorials/176](http://www.sparkfun.com/tutorials/176). Also where you can find people explaining why you need to use a bigger buffer.

As to the first part of what I posted (the first code post)- that's Mikal Hart's own comment- not mine. The way the LS20031 comes, it's baud rate is set at 57600. As Mikal has said on his web site that most GPS units run at 4800. So our LS20031 is a Speedy Gonzales.

What I pointed out in my second code post, I said to Mikal Hart too. He agreed with me that spelling out which pin goes where in SoftwareSerial nss(TXPIN, RXPIN), was a good idea. One less thing for someone to mess up and it was his idea on his web page in the first place, just that idea didn't get transfered to the example in TinyGPS ver 12.

I am also taking Lady Ada examples at Adafruit to heart with her example of spelling out how the Circuits get hooked up to the Arduino inside your sketch. The one thing I am relearning about C++ is to comment about what you’re doing and why. I don't care how good any code is written, if you can’t remember how the curcuit is wired a year from now, it's not going to help you to recreate your project the next time you want to. Also spelling out which part is being used is a great example as to letting others know what you did, so if they have that part they can wire up their own part. I just didn't leave people hanging with just giving them pin names. I gave a part name too. And I hope people would add their part name and pin assignments in just in case I want to use their part instead of mine.

As to SoftwareSerial adding a ton of characters- Mikal Hart who help write SoftwareSerial said part of why we are having problems is due to the fact that 57600-baud rate is a little too fast for SoftwareSerial, so yes it's adding things to the NMEA sentances that don't belong there. With that said- I had version 9 of TinyGPS and the old version of NewSoftSerial working with Arduino 0022 IDE, before Arduino 1.0 IDE came out. Now, I am trying to get the version 12 of TinyGPS to work with current version of SoftwareSerial. FYI- NewSoftSerial has replaced the old version of SoftwareSerial, but it still has retained the old name of SoftwareSerial.

For the moderators- I am sorry this is getting posted all over the place, but I lost this link to this page. But now, I am going to focus my efforts over at [http://arduino.cc/forum/index.php/topic,85743.msg715082.html](http://arduino.cc/forum/index.php/topic,85743.msg715082.html) -- Locosys LS20031 and Mega ADK  
Thanks  
Blacklab1

---

<div class="post-metadata">

**Author:** ![bradb](https://avatars.discourse-cdn.com/v4/letter/b/ee7513/32.png) [@bradb](https://forum.arduino.cc/u/bradb)\
**Post date:** [March 6, 2012, 7:17am UTC](https://forum.arduino.cc/t/help-with-tinygps-and-ls20031-gps-5hz-receiver-resolved/89071/8 "2012-03-06T07:17:33Z")

</div>

> BlackLab1:  
> Also where you can find people explaining why you need to use a bigger buffer.

An alternative solution is from the Sparkfun LS20031 product page ([http://www.sparkfun.com/products/8975](http://www.sparkfun.com/products/8975)) where you can find the commands needed to set the update rate to 1Hz and the baud rate to something a bit more useful (at least for SoftwareSerial).

Of course you do need a way to deal with the 3.3v TTL serial line levels.

I should mention that I typically do this and have discovered if you leave the gps unused for a long period of time (I think mine sat here for a year) it will revert back to the default settings and need to be reprogrammed again.

Brad (KF7FER)

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [March 8, 2012, 10:48pm UTC](https://forum.arduino.cc/t/help-with-tinygps-and-ls20031-gps-5hz-receiver-resolved/89071/9 "2012-03-08T22:48:28Z")

</div>

> [@](#):
>
> An alternative solution is from the Sparkfun LS20031 product page ([http://www.sparkfun.com/products/8975](http://www.sparkfun.com/products/8975)) where you can find the commands needed to set the update rate to 1Hz and the baud rate to something a bit more useful (at least for SoftwareSerial).
> 
> Of course you do need a way to deal with the 3.3v TTL serial line levels.
> 
> I should mention that I typically do this and have discovered if you leave the gps unused for a long period of time (I think mine sat here for a year) it will revert back to the default settings and need to be reprogrammed again.
> 
> Brad (KF7FER)

Thanks Brad-  
Hey, let me give you a leg up too...  
Take a look here \>\> [LOCOSYS high-quality GPS, GNSS, RTK MODULE, TRACKER, IOT, 4G, 5G, Timing, Drone, autonomous vehicle manufacturer from Taiwan | LOCOSYS Technology Inc.](http://www.locosystech.com/product.php?zln=en&id=20) . I have no clue as to how long they will leave that up. But if you click on the down load tab and sign in their web page you can get to the v 1.3 datasheet for the LS2003x. They have the $PMTK251 sentences along with the $PMTK314 sentences that’s everybody is after.

I found out why we are not getting the DATE from the example from TinyGPS- it has to do with TinyGPS is not getting the $GPRMC sentences. Now here’s the weird part coming from SoftwareSerial, 300 lines and not once did I see a RM or MC next to each other. You have to have both to get $GPRMC. It makes me wonder why or what SoftwareSerial is doing to prevent $GPRMC from showing up. But it’s not just not showing up with the beginning of $GPRMC, the whole sentence is missing. These sentences come in a order, and from what I can tell SoftwareSerial loves $GPGLL and tries to merge $GPGGA with something else. That kind of explains why I am seeing so many other people not getting the DATE too.

Once I figure out how to use a voltage Level Translator (so I don’t fry the GPS while talking to the GPS), I will try cutting out all the clutter (everything else but $GPGGA and $GPRMC) and see how if SoftwareSerial will warm up to me. Not frying the 3volt GPS while talking to the GPS is a totally another type of issue.

I posted some of this information over at Mikal Hart web page, and again I want to thank him for his patients with all us newbies to TinyGPS.

-Blacklab1

---

<div class="post-metadata">

**Author:** ![bradb](https://avatars.discourse-cdn.com/v4/letter/b/ee7513/32.png) [@bradb](https://forum.arduino.cc/u/bradb)\
**Post date:** [March 9, 2012, 3:16am UTC](https://forum.arduino.cc/t/help-with-tinygps-and-ls20031-gps-5hz-receiver-resolved/89071/10 "2012-03-09T03:16:31Z")

</div>

> BlackLab1:  
> I have no clue as to how long they will leave that up. But if you click on the down load tab and sign in their web page you can get to the v 1.3 datasheet for the LS2003x.

Thanks, that's useful.

> I found out why we are not getting the DATE from the example from TinyGPS- it has to do with TinyGPS is not getting the $GPRMC sentences.

This is interesting. I read the thread because I've used the LS20031 with TinyGPS and never had a problem. Of course last time I was simply using TinyGPS for testing and was only concentrating on getting a fix, not extracting the data.

> It makes me wonder why or what SoftwareSerial is doing to prevent $GPRMC from showing up.

I'll do a test tonight, but it's not SoftwareSerial - I suspect it's the GPS itself. After all, it is possible to program which NMEA sentences it returns, so I'd guess the default setting is to produce GPRMC.

Brad.

---

<div class="post-metadata">

**Author:** ![bradb](https://avatars.discourse-cdn.com/v4/letter/b/ee7513/32.png) [@bradb](https://forum.arduino.cc/u/bradb)\
**Post date:** [March 9, 2012, 3:36am UTC](https://forum.arduino.cc/t/help-with-tinygps-and-ls20031-gps-5hz-receiver-resolved/89071/11 "2012-03-09T03:36:50Z")

</div>

> [@](#):
>
> I'll do a test tonight, but it's not SoftwareSerial - I suspect it's the GPS itself. After all, it is possible to program which NMEA sentences it returns, so I'd guess the default setting is to produce GPRMC.

Ok so I'm wrong: by default the GPS seems to be sending all the NMEA sentences. I tested this by connecting my LS20031 to a 3.3v USB/TTL Serial adapter and monitored the output with a terminal emulator.

I verified that by default, the sentences output are indeed GGA, GLL, GSV, RMC, and VTG.

So if you're not getting the RMC sentences they are either disabled or perhaps garbled (which doesn't seem likely given your comments).

FWIW,

Brad.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [March 9, 2012, 10:40pm UTC](https://forum.arduino.cc/t/help-with-tinygps-and-ls20031-gps-5hz-receiver-resolved/89071/12 "2012-03-09T22:40:00Z")

</div>

Brad- if you go over to Mikal's Hart's web site he gives a way to see what TinyGPS is seeing [TinyGPS&nbsp;|&nbsp;Arduiniana](http://arduiniana.org/libraries/tinygps/). I have been playing with it and SoftwareSerial from what I am seeing is not passing the $GPRMC sentence (in my case)- which has the DATE information in it. I went so far as dumping to the monitor 300+ sentences and when through them by hand, and not once did I see anything that had a 'R' or a 'M' or a 'C' in it. It went so far as that there was no match for even what is suppose to be in the $GPRMC sentence.

I have been reluctant to post what I have only because I have way too much information. I have posted here \>\> [http://arduino.cc/forum/index.php/topic,85743.msg715082.html](http://arduino.cc/forum/index.php/topic,85743.msg715082.html) 12 or 15 sentences example of both good and bad NMEA messages (sentences) , which you can clearly see what I am seeing.

I was thinking of posting this on the other link on the LS2003x but on second thought I will post it here.  
Thanks  
Blacklab1

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [March 10, 2012, 12:26am UTC](https://forum.arduino.cc/t/help-with-tinygps-and-ls20031-gps-5hz-receiver-resolved/89071/13 "2012-03-10T00:26:54Z")

</div>

Some of this information comes from the data sheet for the LOCOSYS LS2003x.  
You can find it here \>\> [http://www.locosystech.com/product.php?zln=en&id=20](http://www.locosystech.com/product.php?zln=en&id=20) .

As Mikal Hart has stated using the following code can help in the debugging as to why you’re not seeing things you need from Tiny. As he says “…it’s hard to answer the question without seeing the data stream that TinyGPS is given. …  
…  
Either way, the easiest way to debug is to display the raw NMEA sentences. In the test\_with\_gps\_device sample, this means changing feedgps from:

```arduino
   while (nss.available())
  {
    if (gps.encode(nss.read()))
      return true;
  }

```

to

```arduino
while (nss.available())
  {
    char c = nss.read();
    Serial.write(c);
    if (gps.encode(c))
      return true;
  }

```

Again, that code will let you see what softwareSerial is putting out only. It will not show you what the GPS is actually is puting out.

But the following Code, which came from Sparkfun, can give you clean sentences directly from the GPS. \>\>

```arduino
void setup() {
  Serial.begin(57600); 
}
void loop() {
  if (Serial.available()) {
    #if ARDUINO >= 100 //For Arduino v1.0+
    Serial.write(char(Serial.read()));
    #else //For Arduino v0023 or earlier
    Serial.print(Serial.read(), BYTE);
    #endif
   }
}

```

The reason I am posting this here is because the two NMEA headers, in blue, is what TinyGPS looks at to give you the data you are looking for. If these headers are missing, you will not get the data that goes with them.

From Locosys \>\>  
5 Software interface  
5.1 NMEA output message  
_Table 5.1-1 NMEA output message_

* * *

**NMEA record | Description**

* * *

GGA | Global positioning system fixed data \< ---

* * *

GLL | Geographic position - latitude/longitude

* * *

GSA | GNSS DOP and active satellites

* * *

GSV | GNSS satellites in view

* * *

RMC | Recommended minimum specific GNSS data \< ---

* * *

VTG | Course over ground and ground speed

* * *

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [March 10, 2012, 1:03am UTC](https://forum.arduino.cc/t/help-with-tinygps-and-ls20031-gps-5hz-receiver-resolved/89071/14 "2012-03-10T01:03:16Z")

</div>

More information on the GGA:  
**GGA--- Global Positioning System Fixed Data**  
Table 5.1-2 contains the values for the following example:

**$GPGGA** , **053740.000** ,2503.6319,N,12136.0099,E,1,08,1.1,63.8,M,15.2,M,,0000\*64

_Table5.1- 2 GGA Data Format_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_ **Name | Example | Units | Description** pink_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_Message ID | $GPGGA | | GGA protocol header_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_ **UTC Time** | **053740.000** | | **hhmmss.sss** _  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_Latitude | 2503.6319 | | ddmm.mmmm_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_N/S indicator | N | | N=north or S=south_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_Longitude | 12136.0099 | | dddmm.mmmm_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_E/W Indicator | E | | E=east or W=west_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_Position Fix Indicator | 1 | | See Table 5.1-3_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_Satellites Used | 08 | | Range 0 to 12_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_HDOP | 1.1 | | Horizontal Dilution of Precision_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_MSL Altitude | 63.8 | mters |_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_Units | M | mters |_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_Geoid Separation | 15.2 | mters |_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_Units | M | mters |_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_Age of Diff. Corr. | | second | Null fields when DGPS is not used_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_\*Diff. Ref. Station ID | 0000 | | \*_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_Checksum | \*64 | |_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
 _| | | End of message termination_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_Table 5.1-3 Position Fix Indicators_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_ **Value | Description** _  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_0 | Fix not available or invalid_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_1 | GPS SPS Mode, fix valid_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_2 | Differential GPS, SPS Mode, fix valid_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_3-5 | Not supported_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_6 | Dead Reckoning Mode, fix valid_  
_More information on the RMC:_  
_ **RMC---Recommended Minimum Specific GNSS Data** _  
_Table 5.1-9 contains the values for the following example:_  
_ **$GPRMC** ,053740.000,A,2503.6319,N,12136.0099,E,2.69,79.65, **100106** ,,,A\*53_  
_Table 5.1-9 RMC Data Format_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_Name | Example | Units | Description_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_Message ID | **$GPRMC** | | RMC protocol header_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_ **UTC Time** | **053740.000** | | **hhmmss.sss** _  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_Status | A | | A=data valid or V=data not valid_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_Latitude | 2503.6319 | | ddmm.mmmm_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_N/S Indicator | N | | N=north or S=south_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_Longitude | 12136.0099 | | dddmm.mmmm_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_E/W Indicator | E | | E=east or W=west_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_Speed over ground | 2.69 | knots | True_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_\*Course over ground | 79.65 | degrees | \*_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_ **Date** | **100106** | | **ddmmyy** _  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_Magnetic variation | | degrees |_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_Variation sense | | | E=east or W=west (Not shown)_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_Mode | A | | A=autonomous, D=DGPS, E=DR, N=Data not valid,_  
_\* | | | R=Coarse Position, S=Simulator\*_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
_Checksum | \*53 | |_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__  
 _| | | End of message termination_  
_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [March 12, 2012, 12:55am UTC](https://forum.arduino.cc/t/help-with-tinygps-and-ls20031-gps-5hz-receiver-resolved/89071/15 "2012-03-12T00:55:59Z")

</div>

**If you really cant get SoftwareSerial to work- Try this \>\>**

Warning- if you already using PIN 0 (RX) on your UNO like Arduino- this will not work.  
But if you have the RX pin open, and are willing to wire it, try this.

```cpp
// GPS_LS20031_TEST_USES_MONITOR

#include <TinyGPS.h> // You will need TinyGPS from Mikal Hart's web page if you don't have it.

/* This sample code demonstrates the normal use of a TinyGPS object.
   It DOES NOT requires the use of SoftwareSerial, and assumes that you have a
   57600-baud serial GPS device hooked up on pins (TX) and PIN 0(RX) of your Arduino.
   If you’re using a MEGA you will have to use the correct RX pin for MEGA.
   
   IF you are already using PIN 0(RX)on your Arduino for something else
   then this program may not work for you. 
   
   Also you’re going to need to remove the connection between your RX pin on your
   Arduino and the GPS every time you programming the Arduino.
   I forgot this issue a few times.

  The Circuit:
     Pin assignments for the LS20031 GPS: 
     • GPS Pin 5 (left-most when viewed from above) : No connection (or ground)
     • GPS Pin 4 : to Arduino ground (GND) pin
     • GPS Pin 3 : to Arduino pin 0
     • GPS Pin 2 : No connection
     • GPS Pin 1 (right-most when viewed from above) : to Arduino 3.3V pin

  Note: you can use your own GPS with this, just make sure it output from the GPS is connected to the RX pin on your Arduino.     
*/

TinyGPS gps;
// SoftwareSerial nss( RXPIN, TXPIN); // NOT NEEDED IN THIS EXAMPLE
static void gpsdump(TinyGPS &gps);
static bool feedgps();
static void print_float(float val, float invalid, int len, int prec);
static void print_int(unsigned long val, unsigned long invalid, int len);
static void print_date(TinyGPS &gps);
static void print_str(const char *str, int len);

void setup()
{
  Serial.begin(57600);
  //nss.begin(57600); // -- NOT NEEDED IN THIS EXAMPLE
  
  Serial.print("Testing TinyGPS library v. "); Serial.println(TinyGPS::library_version());
  Serial.println("by Mikal Hart");
  Serial.println();
  Serial.print("Sizeof(gpsobject) = "); Serial.println(sizeof(TinyGPS));
  Serial.print("Serial Buffer size = ");Serial.println(" ?? ");            //(_SS_MAX_RX_BUFF); I am not sure how to address this- comes
                                                                                               // directly from the RX buffer
  Serial.println();
  Serial.println("Sats HDOP Latitude Longitude Fix  Date       Time       Date Alt     Course Speed Card  Distance Course Card  Chars Sentences Checksum");
  Serial.println("          (deg)    (deg)     Age                        Age  (m)     --- from GPS ----  ---- to London  ----  RX    RX        Fail");
  Serial.println("--------------------------------------------------------------------------------------------------------------------------------------");
}

void loop()
{
  bool newdata = false;
  unsigned long start = millis();
  
  // Every second we print an update
  while (millis() - start < 1000)
  {
    if (feedgps())
      newdata = true;
  }
  
  gpsdump(gps);
}

static void gpsdump(TinyGPS &gps)
{
  float flat, flon;
  unsigned long age, date, time, chars = 0;
  unsigned short sentences = 0, failed = 0;
  static const float LONDON_LAT = 51.508131, LONDON_LON = -0.128002;
  
  print_int(gps.satellites(), TinyGPS::GPS_INVALID_SATELLITES, 5);
  print_int(gps.hdop(), TinyGPS::GPS_INVALID_HDOP, 5);
  gps.f_get_position(&flat, &flon, &age);
  print_float(flat, TinyGPS::GPS_INVALID_F_ANGLE, 9, 5);
  print_float(flon, TinyGPS::GPS_INVALID_F_ANGLE, 10, 5);
  print_int(age, TinyGPS::GPS_INVALID_AGE, 5);

  print_date(gps);

  print_float(gps.f_altitude(), TinyGPS::GPS_INVALID_F_ALTITUDE, 8, 2);
  print_float(gps.f_course(), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2);
  print_float(gps.f_speed_kmph(), TinyGPS::GPS_INVALID_F_SPEED, 6, 2);
  
  // Ternary operation --> condition ? value_if_true : value_if_false 
  print_str(gps.f_course() == TinyGPS::GPS_INVALID_F_ANGLE ? "***" : TinyGPS::cardinal(gps.f_course()), 6);
  print_int(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0UL : (unsigned long)TinyGPS::distance_between(flat, flon, LONDON_LAT, LONDON_LON) / 1000, 0xFFFFFFFF, 9);
  print_float(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : TinyGPS::course_to(flat, flon, 51.508131, -0.128002), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2);
  print_str(flat == TinyGPS::GPS_INVALID_F_ANGLE ? "***" : TinyGPS::cardinal(TinyGPS::course_to(flat, flon, LONDON_LAT, LONDON_LON)), 6);

  gps.stats(&chars, &sentences, &failed);
  print_int(chars, 0xFFFFFFFF, 6);
  print_int(sentences, 0xFFFFFFFF, 10);
  print_int(failed, 0xFFFFFFFF, 9);
  Serial.println();
}

static void print_int(unsigned long val, unsigned long invalid, int len)
{
  char sz[32];
  if (val == invalid)
    strcpy(sz, " *******");
  else
    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);
  feedgps();
}

static void print_float(float val, float invalid, int len, int prec)
{
  char sz[32];
  if (val == invalid)
  {
    strcpy(sz, " *******");
    sz[len] = 0;
        if (len > 0) 
          sz[len-1] = ' ';
    for (int i=7; i<len; ++i)
        sz[i] = ' ';
    Serial.print(sz);
  }
  else
  {
    Serial.print(val, prec);
    int vi = abs((int)val);
    // Ternary operation >>condition ? value_if_true : value_if_false 
    int flen = prec + (val < 0.0 ? 2 : 1);
    flen += vi >= 1000 ? 4 : vi >= 100 ? 3 : vi >= 10 ? 2 : 1;
    for (int i=flen; i<len; ++i)
      Serial.print(" ");
  }
  feedgps();
}

static void print_date(TinyGPS &gps)
{
  int year;
  byte month, day, hour, minute, second, hundredths;
  unsigned long age;
  gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age);
  if (age == TinyGPS::GPS_INVALID_AGE)
    Serial.print(" *******   *******    ");
  else
  {
    char sz[32];
    sprintf(sz, "%02d/%02d/%02d %02d:%02d:%02d   ",
        month, day, year, hour, minute, second);
    Serial.print(sz);
  }
  print_int(age, TinyGPS::GPS_INVALID_AGE, 5);
  feedgps();
}

static void print_str(const char *str, int len)
{
  int slen = strlen(str);
  for (int i=0; i<len; ++i) // Ternary operation --> condition ? value_if_true : value_if_false 
    Serial.print(i<slen ? str[i] : ' ');
  feedgps();
}

static bool feedgps()
{
   while (Serial.available())
    {
     if (gps.encode(Serial.read()));
    }
  return false;
}

```

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 6, 2021, 10:36am UTC](https://forum.arduino.cc/t/help-with-tinygps-and-ls20031-gps-5hz-receiver-resolved/89071/16 "2021-05-06T10:36:24Z")

</div>

Closed on May 6, 2021, 10:36am UTC


