Payload Format / Decode for TM-901 / N1C2 sensor from KCS TraceME

You’re not doing any shifting here. See Working with Bytes.

Also, without seeing payloads and expected values: are you sure compass_x and all could not be negative values? If they could be negative then you’ll need sign extension in JavaScript, to ensure it’s working with 32 bits values. See Decrypting messages for dummies - #4 by arjanvanb and assuming MSB, maybe use something like:

var compass_x = bytes[19]<<24>>16 | bytes[20];

Also, the above assumes that values are sent as integer numbers (like 1.2 is sent as 12), which (if true) might need to be divided by some factor to get decimal numbers.

As for the result for heading we can only guess, without seeing any actual values. Note that you can write debug messages to TTN Console while testing; see Payload Formats [HowTo] - #3 by arjanvanb