killing me softly with dtostrf

Hi, I am trying to recreate this project Go to Goat Tracker

but the latitude that I get is converted to 0 after dtostrf which puts me into somewhere in Indonesia along the Equator. can anyone help me how to make it display the latitude properly because I don't understand how dtostrf works. thanks

Setup Complete!
Before dtostrf
Coordinate is : 1.85,103.09
After dtostrf
Coordinate is : 0,103.0883201.889040
//Convert GPS data to strings
dtostrf(,1,6, tmpLat);
dtostrf(gps.location.lng(),1,6, tmpLng);
dtostrf(distanceToOffice/1000, 1,6, tmpDistance);
dtostrf(courseToOffice,1,6, tmpCourse);
dtostrf(gps.speed.kmph(), 1,6, tmpSpeed);
Serial.println("Before dtostrf");
Serial.print("Coordinate is : ");
Serial.println("After dtostrf");
Serial.print("Coordinate is : ");

You're calling twice. Are you sure it's returning the same value both times?

A more fair test would be something like this:

double lat =;
char tmpLat[10];
dtostrf(lat, 1, 6, tmpLat);
Serial.print("Before dtostrf: ");
Serial.print("After dtostrf: ");

You may not be providing enough space in the character arrays for the output. Post ALL the code, using code tags.

I don't understand how dtostrf works.

In that case, [u]read the docs[/u]:

char * dtostrf( double __val, signed char __width, unsigned char __prec, char * __s)

The dtostrf() function converts the double value passed in val into an ASCII representation that will be stored under s. The caller is responsible for providing sufficient storage in s.