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.