Payload Decoder

You can’t; that’s not a valid example as 0xEC51CA41 does not decode to 22.68 but to 25.29…

However, a search gets you Decode float sent by Lopy as Node - #2 by arjanvanb for an implementation of bytesToFloat, which you can use along with:

// Test with 4AEC51CA41 for 74, 25.290000915527344 and 25.290
return {
  sensorID: bytes[0],
  // Take the 4 bytes 1 to 5 (not including), and convert to float:
  value: bytesToFloat(bytes.slice(1, 5)),
  // Unary plus-operator to cast string result of toFixed to a number:
  rounded: +bytesToFloat(bytes.slice(1, 5)).toFixed(3)
};

:warning: An earlier version of bytesToFloat had a bug with its line var bits = ....

Beware when sending floats though:

2 Likes