decimal values in CHAR to FLOAT

Hello,

I have temperature value stored in an array. (e.g. 37,3) as when I dump locations from 0 to 3, I’ll get 51,55,46 and 51 in decimal.

I need to convert those into a float in order to further process them, but I always loose the decimal value on the way.

This is a huge project and to give you an idea, I’ve included some code.

void loaddefaults() 
{
byte value;

  for(int sayman=0; sayman< 30; sayman++) //
      {
       value = EEPROM.read(sayman);
       epromstring[sayman] = value;
      Serial.println("displaying value of epromstring :");
      Serial.println(epromstring[sayman]);
      Serial.println("---------------------------");
      delay(500);
      }

Result:
3
7
.
2

So, I’m sure that data is in including decimal point and data.

Now, When I convert like so,

char epromstring[30];

float minderece;

minderece == epromstring[0]+epromstring[1]+ epromstring[2] + epromstring[3];
Serial.println(minderece);

Result is 37.00

Please note that all data stored is in the same format, that is to say, xx,x.

Is there a way to pass data including decimal into float ?

Thank you.

Please use code tags.

Read this before posting a programming question

You could use "atof", but I'm not sure how it would handle the comma, and you'd have to make sure you have a proper C-style string. Or, you could simply store the float in the EEPROM as a float in the first place.

The atof() function would work of the decimal point was not a comma.

minderece == epromstring[0]+epromstring[1]+ epromstring[2] + epromstring[3];

If it is stored as xx,x

then not only are you adding the ascii value of ',' but you are adding the decimal part as if it were a whole number. You would end up adding 3 + 7 + 44 + 2, which is not 37...

Perhaps?

minderece == (epromstring[0]*10) + epromstring[1] + (float)(epromstring[3]/10);