Hi,
I'm trying to convert a string to a float value with the atof() function. The problem is that it does not return the correct value to me. Using the example below it returns "21.123455" in stead of "21.123456".
What am I doeing wrong here?
Thanks in advance.
void setup() {
Serial.begin(115200); // Start seriele communicatie
}
void loop() {
String str = "21.123456" ;
char carray[str.length() + 1]; //determine size of the array
str.toCharArray(carray, sizeof(carray)); //put sensorString into an array
float test = atof(carray);
Serial.println(test,6); //Edit the 6 to how many digits precision you need
delay(500);
}