Writing meaningful GPS coordinates to a SD card with TinyGPS++ and SD.h- Uno R3

I have a setup that takes the GPS coordinates off of an EM-604A and writes them to an SD card (well, that's all it does now).

I'll save you the details on the first part of the program, since that doesn't matter much. What does matter is right here:

if(newData)
  {    
    dataFile.print("Lat: ");
    dataFile.print(gps.location.lat());
    dataFile.print("\n");
    dataFile.print("Lng: ");
    dataFile.print(gps.location.lng());
    dataFile.print("\n");
  }

This does a good job of accessing latitude and longitude and writing them to a file. However, the result of doing this is the following:

Lng: -92.34
Lat: 38.91
Lng: -92.34
Lat: 38.91
Lng: -92.34

As you can see, it drops the rest of the precision and only gives two digits after the decimal point when it writes the info to the SD card. This is good for a general idea of where the unit was at, but is not precise enough for my application. How would I print out the extra numbers? I don't necessarily need all of them (at least, I don't think I will... yet), but would like the ability to format how many numbers after the decimal point that I get.

but is not precise enough for my application. How would I print out the extra numbers?

The "insignificant" code that you omitted isn't. I'm guessing that dataFile is a File object. The File class derives from the Print class. You should look at the documentation for the Print class. Specifically, see what the optional argument does when printing a float.

As far as I know the SD file.print method doesn't provide any way for you to control the precision for floating point values. To do that you would need to format the float value as a string yourself, and then write the string to the file. This would give you control over how the float value was formatted. The AVR runtime library provides dtostrf() which you can use to format a float value to a string. (You will need to #include <stdlib.h> to use dtostrf.)

PaulS:

but is not precise enough for my application. How would I print out the extra numbers?

The "insignificant" code that you omitted isn't. I'm guessing that dataFile is a File object. The File class derives from the Print class. You should look at the documentation for the Print class. Specifically, see what the optional argument does when printing a float.

That did the trick! Thank you.