Cayenne LPP format: analog data wrong

The library’s code shows that value 407.00 is sent as a 16 bits signed integer, using int16_t val = value * 100, hence as 40,700. That’s too large to fit in a 16 bits signed integer which ranges from -32,768 through 32,767.

In hexadecimal, 40,700 is 0x9EFC which when interpreted as a signed integer is indeed -24,836, which divided by 100 indeed yields -248.36.

It’s quite weird LPP does not provide some generic methods for larger values. Some options:

  • You could (ab)use addTemperature which uses int16_t val = celsius * 10, hence sends 4,070 which fits just fine. Same goes for addBarometricPressure.

  • Or, as you know CO2 values are always positive, you could use addLuminosity which expects an unsigned 16 bits integer, which ranges from 0 through 65,535. If you need the two decimals then you’d have to multiply the float by 100 yourself before adding it to LPP, and divide by 100 after receiving it.

  • Or, just forget about LPP and dive into Working with Bytes and payload functions in TTN Console.


In JavaScript, which needs 4 bytes for proper binary math, sign-extension needs to be applied to get the 4 bytes 0xFFFF9EFC.

1 Like