Convert 2 bytes to an integer

I am using the BLE function ReadBytes to receive data from a Wahoo Cadence and Speed sensor. I am receiving the data but according to the specifications the Cadence is contained in the second and third bytes the time is in the third and fourth bytes. I’ve read through many tutorials but I am still puzzled on how to combine two bytes of data into an integer.


Forum discussions about converting bytes is discussed in these topics:!searchin/mitappinventortest/bytes$20to$20integer|sort:date

Maybe there is something useful that will help you covert two bytes to an integer.

Hello Bill

Try the BLE .ReadIntegers block. If there is no value separator in the data stream, you can split the number received as though it was text (via the segment text - start - length block).

Can you post a link to the message stream documentation, and some sample data?

Short answer:
Assuming unsigned bytes, multiply the first byte by 256 and add it to the second byte.

This is the specification.

For cadence : Byte0 has flags then two bytes for crank revolution. The bytes ares LSO to MSO, so I will try byte1 + byte2 * 256.


Sounds good.

Be sure to test those flag bits, to get the proper displacement into the byte list for the crank revolution. The math block bitwise-and is good for testing flag bits in a byte value (128, 64, 32, ...)