Community discussions

MikroTik App
 
WoZeR
just joined
Topic Author
Posts: 17
Joined: Tue Jul 08, 2014 2:52 am

TG-BT5-OUT Temperature Issue?

Fri Feb 18, 2022 5:28 am

I'm not sure if I'm making a mistake or there is a bug. I was following the documentation at https://help.mikrotik.com/docs/display/ ... nt+formats

I have a TG-BT5-OUT and the advertisement is showing the following: 15ff4f090100bf25feff0200faffa1193b2200000064
Based on the documentation the temperature value should be "a119" in a 8.8 fixed point format. However, a119 (1010000100011001) would set the sign bit to a negative temperature. I'm testing in a room with a temperature of around 23C.

UserData is showing 00 which means the encryption is disabled.
Am I missing something or making a mistake or is there a bug or missing documentation on how to obtain the correct temperature?

Here is my nodered code:
...
//Get Temperature
TempHex = msg.payload.locs[0].tags[i].ed.ad.slice(28, 32);
let TempInt = parseInt(TempHex, 16);
let signed = (TempInt & 0x8000) > 0 ? -1 : 1;
Temp = signed * TempInt  / Math.pow(2, 8);
ad: 15ff4f090100bf25feff0200faffa1193b2200000064
TempHex = a119
Temp = -161.09765625

Here are some extra advertisements:
15ff4f090100e4860000fbffffff211a3c0800000064
15ff4f0901008a760000fdfffcff4019240c00000064
15ff4f090100b2a80100000000004019b00c00000064
15ff4f090100ba3502000300fdff4f19470e00000064
15ff4f090100cf05fdfffcff0100cf1aa71700000064
15ff4f090100898afcfffdfffcff401acf1a00000064
15ff4f09010078eafdfffdff0000cf19e41d00000064
15ff4f090100bf25feff0200faffa1193b2200000064
 
denissMT
MikroTik Support
MikroTik Support
Posts: 49
Joined: Wed May 26, 2021 12:00 pm

Re: TG-BT5-OUT Temperature Issue?

Fri Feb 18, 2022 9:29 am

We have added a note to the guide:
https://help.mikrotik.com/docs/display/ ... nt+formats
Please note that all multi-byte values are in little-endian. Meaning, if, for example, you want to get the temperature value and #14 and #15 octets indicate the temperature as "a1 19" → the real temperature value is going to be (0x19a1)/256 = 25.6 C.

You need to change bytes places, as shown above.
 
WoZeR
just joined
Topic Author
Posts: 17
Joined: Tue Jul 08, 2014 2:52 am

Re: TG-BT5-OUT Temperature Issue?

Sat Feb 19, 2022 3:28 am

Thanks! This was the missing piece I needed.

If anyone is interested in the NodeRed code.
//Loop through tags
for (let i = 0; i < msg.payload.locs[0].tags.length; i++) {
    let TAGMacAddress = msg.payload.locs[0].tags[i].id;
    
    //Get a specific tag
    if (TAGMacAddress == "DC2C6EABCD12") {
        //Get Temperature, Little Endian format
        TempHex1 = msg.payload.locs[0].tags[i].ed.ad.slice(30, 32);
        TempHex2 = msg.payload.locs[0].tags[i].ed.ad.slice(28, 30);
        TempHex = TempHex1 + TempHex2; //Combine the ascii hex

        let TempInt = parseInt(TempHex, 16); //Convert ascii hex to Int

        let signed = (TempInt & 0x8000) > 0 ? -1 : 1; //Check for sign bit
        if (signed == -1) {
            TempSigned = (TempInt - 0x10000) / 256; //Convert to signed number
        } else {
            TempSigned = TempInt / 256;
        }
        
        Temperature = (TempSigned  * 1.8) + 32; //Convert C to F

        //Get Battery
        BatteryHex = msg.payload.locs[0].tags[i].ed.ad.slice(42, 44);
        Battery = parseInt(BatteryHex, 16); //Convert Hex to Integer
    }
}
 
kp3928
just joined
Posts: 20
Joined: Tue Jul 06, 2021 3:47 pm

Re: TG-BT5-OUT Temperature Issue?

Thu May 19, 2022 10:29 am

Related post : viewtopic.php?t=186070

Who is online

Users browsing this forum: giovanni, Google [Bot], IvanEffiz, kolinsmk, qatar2022 and 103 guests