Variable string to float

Hi, I am new to Arudino programming and have a problem converting a variable string to a float.

I have been able to convert a fixed HEX string to a float using the following:

  union
{   
    unsigned long a ;
    float b ;
} u ;


const char *hexString = "BFCE4000";

u.a=strtoul(hexString,NULL,16);
lcd.print(u.b);

But the string that i’m receiving (eventually via serial) is more like the following

<A,BFCE4000>

So I need to strip off all but the hex value, and to check my code I have created a sample array, of possible values:

String results[ARRAYSIZE] = { "<A,BFCE4000>", "<B,00000000>", "<A,BFCE4000>", "<B,C04E4000>", "<A,C533C300>", "<B,C5334200>", "<A,404E4000>", "<B,C09AB000>", "<A,41347800>", "<B,C11AB000>" };

But I can’t get the string to convert to HEX or to a Float, I have spend probably a good 3 hours trying different codes I have found around these forums and Stackoverflow.

I have spend probably a good 3 hours trying different codes

But you decided not to post any of them?

No I wasn’t able to remember all of them as when they didn’t work I deleted them so I didn’t get confused as to what was working and what wasn’t.

I have managed to get it working by converting a String to string using c_str taken from http://forum.arduino.cc/index.php?topic=377440.0

Jaman:

String results[ARRAYSIZE] = { "<A,BFCE4000>", "<B,00000000>", "<A,BFCE4000>", "<B,C04E4000>", "<A,C533C300>", "<B,C5334200>", "<A,404E4000>", "<B,C09AB000>", "<A,41347800>", "<B,C11AB000>" };

But I can’t get the string to convert to HEX or to a Float

Why would you want to do that? All of those hex values can fit in a uint32_t (aka ‘unsigned long’).