androidencodingcharacter-encodingbluetooth-lowenergyarraybuffer

Decode BLE Temperature characteristics value to Celsius


I am using a BLE device to read temperature and get it on my system, but I am stuck on how to parse the encoded value returning from temperature characteristics value.

for eg: I am getting BmsBAP/aBwECAR8AAA== in response from the BLE device, and I am supposed to convert it to exactly 36.3 degree Celsius. some more readings are:

Characteristics value: BmsBAP/aBwECAR8AAA== Device Reading: 36.3 C

Characteristics value: BmwBAP/aBwECASEAAA== Device Reading: 36.4 C

Characteristics value: BmYBAP/aBwECAR0AAA== Device Reading: 35.8 C

BLE device used: FORA IR20 Infrared Thermometer

here is a snippet of code which I tried: https://stackblitz.com/edit/node-92jt2g?file=index.ts

So, need help to find out the correlation between the required temperature and the encoded value being sent from the device.


Solution

  • "BmYBAP/aBwECAR0AAA==" is encoded using Base64 and the hex rappresentation of decoded data is

    You're saying that it stays for "35.8°C" and usually raw data is stored without decimal, so it became "358". 358 could be rapresented as

    As you can see "1", "6" and "6" is present in the initial bytes in "0x66" and "0x01" so you can read/reorder initial bytes like this:

    1. "0x06" seems always the same for all and I don't know what it could be. Maybe the measument unit ID
    2. 0x01 + 0x66 = 0x166 which is 358 = 35.8°C

    If you do same procedure for the others you will get: