haczet
1
I recive this data {0xF6 0x28 0x3F 0x42}
its a float_32
I converted it to HEX 0x423F28F6 = 47.79 float
How do I convert it to float??
I did this
uint32_t voltage = (uint32_t)incoming[5]<<24 | (uint32_t)incoming[4]<<16 | (uint32_t)incoming[3]<<8 | incoming[2];
and as a result I get this 1111435510 witch is 0x423F28F6 in HEX
but I need 47.79 witch is 0x423F28F6 in HEX
Search the forum -- it has been discussed and done many times.
system
3
and as a result I get this 1111435510 witch is 0x423F28F6 in HEX
but I need 47.79 witch is 0x423F28F6 in HEX
Seems to me that what you get is what you want. If you stored the value in a float instead of a long...
haczet
4
solution
uint32_t data = (uint32_t)incoming[5]<<24 | (uint32_t)incoming[4]<<16 | (uint32_t)incoming[3]<<8 | incoming[2];
float voltage = *((float *)&data);