GPS Skylab nav

#include "TinyGPS.h"
#include "SoftwareSerial.h"
#define GPS_RX_PIN 2
#define GPS_TX_PIN 3
TinyGPS gps; // create a TinyGPS object
SoftwareSerial ss(GPS_RX_PIN, GPS_TX_PIN); // create soft serial object
void setup()
{
Serial.begin(115200); // for debugging
ss.begin(9600); // Use Soft Serial object to talk to GPS
}
void loop()
{
while (ss.available())
{
int c = ss.read();
Serial.write(c); // display NMEA data for debug

// Send each byte to encode()
// Check for new position if encode() returns "True"
if (gps.encode(c))
{
long lat, lon;
unsigned long fix_age;
gps.get_position(&lat, &lon, &fix_age);
if (fix_age == TinyGPS::GPS_INVALID_AGE )
Serial.println("No fix ever detected!");
else if (fix_age > 2000)
Serial.println("Data is getting STALE!");
else
Serial.println("Latitude and longitude valid!");
Serial.print("Lat: "); 
Serial.println(lat);
Serial.print(" Lon: "); 
Serial.println(lon);

}
}
}

the output of code is
3027913322
3056336884

and my real location is
30,27913322,30,56336884
i want to convert the data but when i do , the location
be 30,00
30,00

The values you see should be
30279133
30563369
as that function returns millionths of a degree resolution.

Where is this faulty code that converts the data? Are you printing
out float values to default precision perchance?

iMouDa94:
3027913322
3056336884

i want to convert the data [to degrees] but when i do , the location
be 30,00
30,00

I suspect you tried:

float latDegrees = lat / 1000000;
Serial.println(latDegrees);

That would produce a result of "30.00" since the integer division throws away the fractional part of the result and, by default, the println() shows float values with two decimal places. Try:

float latDegrees = lat / 1000000.0;
Serial.println(latDegrees, 6);

Expect the last few decimal places to be wrong because a 'float' can only hold 6 or 7 decimal places, including the places BEFORE the decimal. Trying to print 8 decimal places of a 6 decimal-place value will cause round-off errors.