TinyGPS++ issue

Hi all ,
i have an issue with tiny gps library , so i will explain ...... the issue is that i cannot store
to a variable of my own name lets say name it ( mylat = to (receiver_gps.location.lat())
even if i declare mylat to an int or float or long cannot store receive_gps.location.lat() of the gps++ library to be more specific what kind of variable is it ? (if it is a variable)
i need that so i can calculare more easy my math
what i am doing wrong....

thank all of you in advance
best regards

one thing to say .....
i didnt list my code bz it works with the standard values of the tinyGPs++ library
i just need to transfer the library variable to my own variable

If you don't show us your code, how are we to help?

Please read and follow the instructions in the “How to use this forum” post.

i am sorry thats my short code …

#include <TinyGPS++.h>
#include <SoftwareSerial.h>

int myRXPin = 3;
int myTXPin = 2;
int myValue;
uint32_t myGPS = 9600;

TinyGPSPlus receiver_gps;
SoftwareSerial ss(myRXPin,myTXPin);

void setup() {


void loop() {
while (ss.available()>0)
if (receiver_gps.encode(ss.read()))

myValue = receiver_gps.location.lat();


when i println receiver_gps.location.lat() i get my lattitude correctly to my serial monitor
when i println myValue i have 0 value to my serial monitor

thank you all for your replys

the lat() function returns a floating point number. You are assigning that value to a variable of type 'int' which truncates it to the whole value (which I guess is 0) and discards everything after the decimal point.


//int myValue;
float myValue;

One way to find out what a function returns: Look in the .h file.


struct TinyGPSLocation
   const RawDegrees &rawLat()     { updated = false; return rawLatData; }
   const RawDegrees &rawLng()     { updated = false; return rawLngData; }
   double lat();
   double lng();

So .lat() and .lng() return ‘double’ (which on the UNO and MEGA is the same as ‘float’). That will give you between 6 and 7 digits of precision (about 19m precision). If you want more precision, call rawLat() or rawLng() and pass in a “RawDegrees” struct to be filled in:

struct RawDegrees
   uint16_t deg;
   uint32_t billionths;
   bool negative;

You could always check the web page for TinyGPS++, it tells you what variable type each function returns.

Just type TinyGPS++ into a Google search to find this very useful reference.

i will try all methods

ty :slight_smile:

i tried double (for bucket) for myValue and the result is :

with myValue ( myValue declared as double) = 37.96
with receiver_gps.location.lat() = 37.95954895019531250000

what am i doing wrong…

look my serial monitor

ty all for your time

Thats probably a printing issue.

If you do;


Then by default it only prints 2 decimal places.

Check out the Serial.print reference;


Did you try to just Serial.println( myValue ) or did you do a Serial.println( myValue, 6) . One defaults to just printing 2 decimal places and the other will print 6 decimal places.

ty guys
i will try the last one Serial.println(myValue,6); and i will tell you again ,
i have my gps to a friend and due to coronavirus i cant get there
so i have to wait

hello all,
i finally found my error it was a printing error as was mentioned above
when i typed ,6 to serial print all worked as expected
thank you all,
best regards,