I recently made a thread where I read BLE data that has three different numbers/values. The data changes but it typically looks something like this:
0,5
-0,1
0
I successfully store the three numbers in a unique char* but when I try to convert the char* to a double I get the value 0.0 in return.
This is my code:
while (tok)
{
if (currentRow == 0)
{
currentRow = currentRow +1;
double a = atof(tok);
Serial.println (a);
}
else if (currentRow == 1)
{
currentRow = currentRow+1;
double b = strtod(tok, NULL);
Serial.println (b);
}
else {
currentRow = 0;
double c = atof (tok);
Serial.println (c);
}
tok = strtok(NULL, " ");
}