Im trying to parse the data coming from some sensors, The data I recive is a hexadecimal number f.e.: '450934644ad7a38441' I want to extract the last 8 characters, that are the value for temperature taken, and transform it into a readable number. I tried this website: https://www.scadacore.com/tools/programming-calculators/online-hex-converter/
Here when you input d7a38441 it is processed and the wanted number is under Float - Little Endian (DCBA) system. Also the conversion it`s doing is under UINT32 - Big Endian (ABCD) system
How do I convert this number into float? I Tried reading some other questions here but couldnt find a solution. parseFloat() gives me NaN.
I would appreciate some light.
var data = '450934644ad7a38441';
function main(data) {
var result = [
{
"key": "temperature",
"value": parseInt('0x'+data.substring(10))
}
]
return result;
}
console.log(main(data));
// expected output: Array [Object { key: "temperature", value: 16.58 }]