TinyGPSPlus gives out the location only up to two decimals !

I am working on a GPS project, the problem I have encountered is:

I tried to get the latitude and longitude values to a float variable using:

float latitude = (gps.location.lat());

float longitude = (gps.location.lng());

Here is the result when float/double variable prints on the serial monitor:

Lat: 6.72 (It is said that the value is limited to two decimal places by default when assigned to a variable)
Lng: 80.74

But when print on the serial monitor with following function:

Serial.println(gps.location.lat(),6); (I am aware about the parameter value "6", it sets the no of decimals to display)

Serial.println(gps.location.lng(),6);

Here is the result:

Lat: 6.722522
Lng: 80.735432

Please, help me to assign the full location values (Lat: 6.722522, Lng: 80.735432) to variables for further calculations. I am new to programming. Thanks

1 Like

I don't see your problem.

It is said that the value is limited to two decimal places by default when assigned to a variable

Who says that ?

Please, help me to assign the full location values (Lat: 6.722522, Lng: 80.735432) to variables for further calculations.

Have you tried

float theLat = gps.location.lat();
Serial.println(theLat, 6);

What is printed ?

1 Like

It is said that the value is limited to two decimal places by default when assigned to a variable

Whoever told you that, didn't tell you correctly or you misunderstood.

Default printing will limit the printed output to two decimals; that does not mean that the value stored in the variable is limited to two decimals.

Note that you are not going to get 'float' values accurate to more than 6 to 7 digits (not digits after the decimal; total digits)

If you want a more precise position, use the long integer values which are in millionths of a degree. This gives you 6 digits after the decimal (and up to three before the decimal).