What Data Type do I use for a GPS coordinate?

I'm trying to work out what data type to use when printing a gps coordinate.

char buf[128];
       if (gps.location.isValid()) {
        snprintf(buf, sizeof(buf), "%lf,%lf", gps.location.lat(), gps.location.lng());

I tried to this however it's printing


So I made variables of data type double lat and long equal




respectively. However when I serial print it only prints 2 decimal places which can't be used for a gps coordinate. How do I get it to print the full value?

I've tried long double, long float, char lat[128], long[128], unsigned long but all have issues when trying to Serial.print or they dont change the length of the value.

You really need to study and learn the language (Arduino) before posting questions that clearly reveal you have not read some of the most basic syntax.
Also, the value that's printed is only what is formatted for print and not the value itself. In any math calculation, the full value is used. If transmitting, learn the print and write functions.

You need to turn the floats that are the Lat and Long into character arrays and insert them wity %s into your snprintf.

There is a fully working example to be found in the 'LoRaTracker_HAB2_101017' program which you will find here;

Look for the 'buildHABPacket()' function, it creates a buffer of CSV seperated data.

It's part of a LoRa based high altitude balloon tracker program, range is around 400km @ 10mW.