I’m getting GPS coordinates from another webpage as a String --> converting it into a float. I’ve been able to do this conversion…However, the float gets rounded off to two decimal places. I know float has more precision… wondering what I’m missing. Is there a better way to do this conversion… I would ideally like to convert it to a double but wasn’t sure how to do it…?
The problem is in print/println–default for floats and doubles is 2 decimal places. Try passing the number of digits you want to print to the println function:
Serial.println(longVal, 12);
Everywhere you have float in your code you could have written double for more precision if you need it. The atof() function does return double which your code is casting to float.
Thank you for the suggestion! This worked as well though as a different approach to the code rather than the Serial printing problem(which I fixed as per bko’s response).