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
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).