bluetooth-lowenergysensorsnode-redtexas-instruments

how can i convert byte array from LPSTK-CC1352R temperature to decimal


i try to setup the LPSTK-CC1352R Launchpad with Node RED and a bluetooth connection. the inbuild sensor is a hdc2080 sensor. I'm not a electronic engineer so the datasheets are a bit confusing to me. I made it to the point, where i have a connection to the MCU via bluetooth and get every second the temperature values. Unfortunately i get these values as a 4 dimensional hex array.

[04 4a d5 41]
[dc 44 d5 41]
[b4 3f d5 41]
[8c 3a d5 41]
...

here is a example of values.

I tried a lot to convert them into a simple temperature value but without success. I even found a kind of tutorial, but without success.

Could anyone help me with the convertion?

Thank you :)


Solution

  • You have to reorder the hex values from right to left, because the last hex value is not changing, which means it has to be little endian.

    https://en.wikipedia.org/wiki/Endianness#:~:text=Little%2Dendian%20representation%20of%20integers,visualized%2C%20an%20oddity%20for%20programmers.

    4hex are 32-bit

    converted to IEEE-754 Floating Point:

    [41 d5 4a 04] = 26.6611404419
    [41 d5 44 dc] = 26.6586227417
    [41 d5 3f b4] = 26.6561050415
    [41 d5 3a 8c] = 26.6535873413
    

    https://www.h-schmidt.net/FloatConverter/IEEE754.html