I want to store the NEO 6 M GPS value as it is showing in the serial monitor. I have written a code that shows LAT & LONG values 6 places after the decimal like LATITUDE: 27.263017 and LONG: 83.098321. But when I declare a variable say
long c,d, and then the value stored in c is only 27.26 and d is 83.09. The first time I gave the datatype as a float so there I can understand this fault but even after giving the data type long why this scenario persists? In the Code 6 is written so that it fetches six digits after the decimal.
c= (gps.location.lat(), 6); it stores and showing value 6.00 &
c = gps.location.lat(), 6; also doing the same.
c= gps.location.lat(); it stores and shows value 27.26.
Same problem happening with LONG also.
Can anyone suggests what needs to be done so that the required LAT & LONG values (six places after decimals) can be stored in c and d? A portion of the code has been given as attchment.
long c,d;
if (gps.location.isValid())
{
Serial.print("Latitude: ");
//Serial.println(gps.location.lat(), 6);
c= (those 3 sentences mentioned above);
Serial.println(c);
Serial.print("Longitude: ");
Serial.println(gps.location.lng(), 6);
Serial.print("Altitude: ");
Serial.println(gps.altitude.meters());
Serial.print("Speed in m/s = ");
Serial.println(gps.speed.mps());
//Serial.print("Number of satellites in use = ");
//Serial.println(gps.satellites.value());
}
else
{
Serial.println("Location: Not Available");
I can't tell if the problem is that Serial.print(doubleVal) prints a default 2 digits, That doubles on Arduinos are really floats with only 6-7 digits of precision, or that you are casting floats to longs.
Arduino UNO board has been used. TinyGPS++.h and SoftwareSerial.h libraries have been used.
Pardon me for my poor English understanding. For the second half of your comment, I can tell you that NEO 6M GPS gives LAT LONG values 14 points after the decimal. All the values after decimal are LAT LONG values. The value given by NEO 6M (with six digits after decimal)has been crosschecked in Google Earth and it has approximately 4 meter positional error. So as far as I am thinking all these are LAT LONG values ( complete set means six points after decimal. but my problem is same which i mentioned earlier.
On an Uno, the floats would get you only 6-7 significant digits, and if you use a couple for degrees, you don't get the 6-7 significant figures apst the decimal : float - Arduino Reference
4 m precision is between 4-5 decimal digits of degrees, which might be expected from a 6-7 significant digit float/(uno double).
An Uno will print as many digits of a floating point number as you ask for, but the value will get filtered through a float and just print garbage past 6-7 significant digits :
Serial.print(PI,30); // prints 3.141592741012573242187500000000 on an Uno
Per
...you could use the rawLat() and rawLon() attributes to get the high precision coordinates, but they are split into components.