I’ve got a project where I’m reading the temperature of a Peltier controller using RS232. I send a temperature read command and I get that command echoed back followed by the temperature in Hex IEE 754 format.
I send: “$RN100?” - This looks for the temperature stored in register 100 of the Peltier controller.
Then i get “$RN100? 41C80580”
Doing the converstion of 41C80580 to decimal using this Website I get the number 25.002686 (the controller is set to control at 25 so this sounds right.)
I’m using Serial.readStringUntil() so my 41C80580 number is still a string in the Arduino.
So my question is how do i both convert the string to a long or a float and make sure it displays correctly for example 41C80580 displaying as 25?
Looked around on google a bit more and i can use:
long number = strtol( &hexstring, NULL, 16);
to change the hex string to a long. This is great it means I only need to find out how to convert my number to IEE 754 format now.