PaulS:
char buf[7];while ((n = file.read(buf, sizeof(buf))) > 0)if (strlen(buf)==9)strlen() is a string function. It, therefore, expects a NULL terminated array of chars. Unpredictable results can be expected if you pass it something other than a string.
Leaving aside the fact that you refuse to properly NULL terminate the string, how do you expect to get strlen() to measure that there are indeed 9 characters in the 7 element array?
temperatura = atof(buf);atof() is also a string function. It, therefore, expects a NULL terminated array of chars. Unpredictable results can be expected if you pass it something other than a string.
Hello!
I don't know to explain why the length of the string is equal to 9.
Did a Serial .print (strlen(buf)) and the program returned 9 for all strings.
As for the NULL terminator, the program recognizes the end of the string even without it.
If I have problems I change the program and acrescentor the terminator.