TinyGps++ latitude 58.12345 to variable

Hello all.
I am struggling on how to get this:
printFloat(gps.location.lat(), gps.location.isValid(), 11, 6);

into a variable so i can send it to php/sql

I have tried:
GPSlatt = (gps.location.lat()); Serial.print("GPSlat = "); Serial.println(GPSlatt);

with:
int GPSlatt;
or
String GPSlatt;

I have not got the hang of types of data yet.

Correct output would be: 58.127242

printFloatI think there's a clue there.

Yes, but how can i make it to a variable?

printFloat

Like this?

GPSlatt = printFloat(gps.location.lat());

Nope...

exit status 1
too few arguments to function 'void printFloat(float, bool, int, int)'

Try dtostrf instead.

but should it be int or float or something when i declare it?

You were using printFloat to print the return value of GPS.location.lat.

Do you think it should be an int?

I have not got the hang of types of data yet.

Why not google “C/C++ data types” and spend a few minutes browsing through all the well-written tutorials?

I have not got the hang of types of data yet.

Bit like saying you going on a long car journey, but have not got the hang of steering yet.

I have tried:
GPSlatt = (gps.location.lat()); Serial.print("GPSlat = "); Serial.println(GPSlatt);

with:
int GPSlatt;
or
String GPSlatt;

gps.location.lat() returns a float, not a string or an int.

I am getting there.... AWOL :slight_smile:

Now i have figured out that i need to use:

float GPSlong = (gps.location.lng()); Serial.print("GPSlng = "); Serial.println(GPSlong);

But, it gives me: GPSlng = 7.96
Expecting: GPSlng = 7.956120

float GPSlong = (gps.location.lng(), 6); Serial.print("GPSlng = "); Serial.println(GPSlong);
This gives me just 6.00
Any hint on how to get the rest in there??? :slight_smile:

Thank you, jremington, for the foot up my ass.... :slight_smile:
Yes, srnet, that's right. I really have no clue what i am doing.

Serial.print("GPSlng = "); Serial.println(GPSlong, 4);

RTFM early, RTFM often

B4x4:
Yes, srnet, that's right. I really have no clue what i am doing.

Then find the reference page for the command you are using, much quicker to research this stuff yourself thangetting the forum to do it for you, Google this;

Arduino serial print reference

And as if by magic you should find a page which tells you in the second line of description why you only get two decimal places printed .......................

It took me 3 hours to figure out that I allways get all the digits, but its how its displayed i need to figure out. :slight_smile: