Decode LoRaWan Payload (Dragino LHT65)

Hi, I connected a Dragino Air Sensor (LHT65 1.7.3) via Chirpstack and the build in mosquitto broker to nodered.
Now I use the buffer parser to decode the payload, but having problems to understand the decoding.

For example the payload is CB F6 0B 0D 03 76 01 0A DD 7F FF

CF F6 represents the voltage, but not directly and I don´t get it.
0B 0D and 03 76 are int16 be and are representing the temp and humidity, that´s ok.

Here the screenshot of the user manual 1.7.3 regarding the voltage:

it would be great if someone could help me interpret the instructions (0xCBF6>>14)&0xFF=11(B).
Cheers

You need to find the decoder then you can do it in a function node. Look on the web and TTN github.

Can you also show me the JSON you recive from your mqtt connection?

Please post code and JSON with the </> tab.

in the meantime we have rewritten the decoder based on Dragino's template and it works.
From this point on, I am only interested in learning how to work with different data formats.
And I realized that the argument 3FFF is a fixed Value (16383) and only a part of the calculation and not a part in the hex string... :grimacing:

Here the solved decoder if someone is interested:

Our LHT65 decoder looks like this (for Chirpstack v4).

function decodeUplink(input) {
        return { 
            data: Decode(input.fPort, input.bytes, input.variables)
        };   
}

function Decode(fPort, bytes, varaiables) {
//Payload Formats of LHT65 Deveice
  return {
    
       //External sensor
       Ext_sensor:
       {
         "0":"No external sensor",
         "1":"Temperature Sensor",
         "4":"Interrupt Sensor send",
         "5":"Illumination Sensor",
         "6":"ADC Sensor",
         "7":"Interrupt Sensor count",
       }[bytes[6]&0x7F],
       
       //Battery,units:V
       BatV:((bytes[0]<<8 | bytes[1]) & 0x3FFF)/1000,
       
       //SHT20,temperature,units:℃
       TempC_SHT:((bytes[2]<<24>>16 | bytes[3])/100).toFixed(2),
       
       //SHT20,Humidity,units:%
       Hum_SHT:((bytes[4]<<8 | bytes[5])/10).toFixed(1),
       
       //DS18B20,temperature,units:℃
       TempC_DS:
       {
         "1":((bytes[7]<<24>>16 | bytes[8])/100).toFixed(2),
       }[bytes[6]&0xFF],       
       
       //Exti pin level,PA4
       Exti_pin_level:
       {
         "4":bytes[7] ? "High":"Low",
       }[bytes[6]&0x7F], 
       
       //Exit pin status,PA4
       Exti_status:
       {
         "4":bytes[8] ? "True":"False",
       }[bytes[6]&0x7F],    
       
       //BH1750,illumination,units:lux
       ILL_lx:
       {
         "5":bytes[7]<<8 | bytes[8],
       }[bytes[6]&0x7F],  

        //ADC,PA4,units:V
        ADC_V:
       {
         "6":(bytes[7]<<8 | bytes[8])/1000,
       }[bytes[6]&0x7F],  
       
        //Exti count,PA4,units:times
        Exit_count:
        {
          "7":bytes[7]<<8 | bytes[8],
        }[bytes[6]&0x7F],  
        
        //Applicable to working mode 4567,and working mode 467 requires short circuit PA9 and PA10
        No_connect:
        {
          "1":"Sensor no connection",
        }[(bytes[6]&0x80)>>7],  
  };
}

Here is my NodeRed flow.

[
    {
        "id": "926c5b1cba1dd566",
        "type": "debug",
        "z": "8e1d1068687d2153",
        "name": "debug 19",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 260,
        "y": 260,
        "wires": []
    },
    {
        "id": "b2d8169f1de51eab",
        "type": "change",
        "z": "8e1d1068687d2153",
        "name": "extract .frm_payload",
        "rules": [
            {
                "t": "move",
                "p": "payload.data",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 360,
        "y": 320,
        "wires": [
            [
                "4f2ea98c93061fae",
                "7c7bd91f8e1688dd"
            ]
        ]
    },
    {
        "id": "c50383831a5452b6",
        "type": "buffer-parser",
        "z": "8e1d1068687d2153",
        "name": "LHT65",
        "data": "payload",
        "dataType": "msg",
        "specification": "spec",
        "specificationType": "ui",
        "items": [
            {
                "type": "int16be",
                "name": "v",
                "offset": 0,
                "length": 1,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "int16be",
                "name": "temp_luft",
                "offset": 2,
                "length": 1,
                "offsetbit": 0,
                "scale": "/100",
                "mask": ""
            },
            {
                "type": "int16be",
                "name": "humidity",
                "offset": 4,
                "length": 1,
                "offsetbit": 0,
                "scale": "/10",
                "mask": ""
            }
        ],
        "swap1": "",
        "swap2": "",
        "swap3": "",
        "swap1Type": "swap",
        "swap2Type": "swap",
        "swap3Type": "swap",
        "msgProperty": "payload",
        "msgPropertyType": "str",
        "resultType": "value",
        "resultTypeType": "return",
        "multipleResult": true,
        "fanOutMultipleResult": true,
        "setTopic": true,
        "outputs": 3,
        "x": 790,
        "y": 340,
        "wires": [
            [
                "57d5ba1b0baefea0"
            ],
            [
                "997506b73907f3fe"
            ],
            [
                "37edcf19737e8cb4"
            ]
        ]
    },
    {
        "id": "7c7bd91f8e1688dd",
        "type": "base64",
        "z": "8e1d1068687d2153",
        "name": "",
        "action": "",
        "property": "payload",
        "x": 600,
        "y": 320,
        "wires": [
            [
                "781b61f457d8a98d",
                "c50383831a5452b6"
            ]
        ]
    },
    {
        "id": "781b61f457d8a98d",
        "type": "debug",
        "z": "8e1d1068687d2153",
        "name": "debug 20",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 760,
        "y": 260,
        "wires": []
    },
    {
        "id": "4f2ea98c93061fae",
        "type": "debug",
        "z": "8e1d1068687d2153",
        "name": "debug 21",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 540,
        "y": 260,
        "wires": []
    },
    {
        "id": "37edcf19737e8cb4",
        "type": "debug",
        "z": "8e1d1068687d2153",
        "name": "debug 22",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1000,
        "y": 460,
        "wires": []
    },
    {
        "id": "997506b73907f3fe",
        "type": "debug",
        "z": "8e1d1068687d2153",
        "name": "debug 23",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1000,
        "y": 420,
        "wires": []
    },
    {
        "id": "4f27b16a61dbf856",
        "type": "inject",
        "z": "8e1d1068687d2153",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"deduplicationId\":\"deleted\",\"time\":\"2022-11-29T13:28:13.589268+00:00\",\"deviceInfo\":{\"tenantId\":\"deleted\",\"tenantName\":\"ChirpStack\",\"applicationId\":\"deleted\",\"applicationName\":\"deleted\",\"deviceProfileId\":\"deleted\",\"deviceProfileName\":\"OTAA\",\"deviceName\":\"luft_test\",\"devEui\":\"deleted\"},\"devAddr\":\"deleted\",\"adr\":true,\"fPort\":2,\"data\":\"y+cDBgPHAX//f/8=\",\"rxInfo\":[{\"gatewayId\":\"deleted\",\"uplinkId\":8409,\"time\":\"2022-11-29T13:28:13.589268+00:00\",\"rssi\":-55,\"snr\":5.5,\"channel\":5,\"location\":{},\"context\":\"lIY0lA==\",\"metadata\":{\"region_name\":\"eu868\",\"region_common_name\":\"EU868\"}}],\"txInfo\":{\"frequency\":867500000,\"modulation\":{\"lora\":{\"bandwidth\":125000,\"spreadingFactor\":12,\"codeRate\":\"CR_4_5\"}}}}",
        "payloadType": "json",
        "x": 130,
        "y": 320,
        "wires": [
            [
                "b2d8169f1de51eab",
                "926c5b1cba1dd566"
            ]
        ]
    },
    {
        "id": "57d5ba1b0baefea0",
        "type": "function",
        "z": "8e1d1068687d2153",
        "name": "function 2",
        "func": "msg.payload = (msg.payload + 16383) / 1000\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1000,
        "y": 320,
        "wires": [
            [
                "d76c72a83ba7ecc8"
            ]
        ]
    },
    {
        "id": "d76c72a83ba7ecc8",
        "type": "debug",
        "z": "8e1d1068687d2153",
        "name": "debug 26",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1180,
        "y": 320,
        "wires": []
    }
]

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.