16bit signed temperature from buffer, Dynet protocol

Hello all, attempting to create a dashboard of temperatures in Celsius from Dynalite light switches. These are on an RS485 throughout the house, I can see the temperature regular broadcasts in the Windows app.

I've connected to the serial server from Nodered and am parsing bytes off the wire ok, using the node-red-contrib-buffer-parser module. But I can't convert the data Hi + Lo bytes back into a decimal/float.

In the Dynet documentation it says the 3rd byte is the opcode and 0x0C indicates data hi low (5th and 6th byte) will contain the temperature.

0x0C = Actual Temperature (w/o Temperature Offset), as signed fixed point Q7.8 deg celsius (Range -127.99 to 127.99)

Examples buffer, should be +20.04 degrees celsius:

Same packet shown in the manager software:

Any help appreciated.

@natm

That Q format suggests the value will be xxxxxxx.yyyyyyyy - but that is not possible from 2 bytes. It would make more sense if it said Q3.2

Any how, looking at the packet picture, it look like they concatenate bytes [4] and [5] as strings either side of a decimal point.

Here is a demo...

yVOlmxqKrD

[{"id":"1708eb74.dca695","type":"inject","z":"64ce1d00.d049e4","name":"go","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":210,"y":580,"wires":[["9b7c388a.66a0e8"]]},{"id":"9b7c388a.66a0e8","type":"function","z":"64ce1d00.d049e4","name":"0x1c,     23,     0xc,     0x4a,     0x14,     0x4,     0xff,     0x60 (20.04)","func":"msg.payload = Buffer.from([\n    0x1c,\n    23,\n    0xc,\n    0x4a,\n    0x14,\n    0x4,\n    0xff,\n    0x60,\n])\nreturn msg;","outputs":1,"initialize":"","finalize":"","x":470,"y":580,"wires":[["a73927a0.0a7a18"]]},{"id":"f39df2ff.df304","type":"buffer-parser","z":"64ce1d00.d049e4","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int8","name":"Temp1","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int8","name":"Temp2","offset":5,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":990,"y":620,"wires":[["57669557.1ffabc"]]},{"id":"a73927a0.0a7a18","type":"switch","z":"64ce1d00.d049e4","name":"byte[2] == 0xc?","property":"payload[2]","propertyType":"msg","rules":[{"t":"eq","v":"0xc","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":800,"y":620,"wires":[["f39df2ff.df304"]]},{"id":"848663a0.c0b31","type":"debug","z":"64ce1d00.d049e4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload.Temperature","statusType":"msg","x":970,"y":660,"wires":[]},{"id":"580decf8.0d6474","type":"inject","z":"64ce1d00.d049e4","name":"go","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":210,"y":620,"wires":[["cd24b823.918d88"]]},{"id":"cd24b823.918d88","type":"function","z":"64ce1d00.d049e4","name":"0x1c,     0x1f,     0xc,     0x4a,     0x16,     0x11,     0xff,     0x49 (22.17)","func":"msg.payload = Buffer.from([\n    0x1c,\n    0x1f,\n    0xc,\n    0x4a,\n    0x16,\n    0x11,\n    0xff,\n    0x49,\n])\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":470,"y":620,"wires":[["a73927a0.0a7a18"]]},{"id":"5993359a.1ac49c","type":"function","z":"64ce1d00.d049e4","name":"0x1c,     0x1f,     0xc,     0x4a,     0x10,     0x53,     0xff,     0x49 (16.83)","func":"msg.payload = Buffer.from([\n    0x1c,\n    0x1f,\n    0xc,\n    0x4a,\n    0x10,\n    0x53,\n    0xff,\n    0x49,\n])\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":480,"y":660,"wires":[["a73927a0.0a7a18"]]},{"id":"a5ce6e63.4d84b","type":"inject","z":"64ce1d00.d049e4","name":"go","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":210,"y":660,"wires":[["5993359a.1ac49c"]]},{"id":"57669557.1ffabc","type":"function","z":"64ce1d00.d049e4","name":"to Q3.2","func":"var s1 = msg.payload.Temp1;\nvar s2 = (msg.payload.Temp2 + \"\").padStart(2,\"0\");\nmsg.payload.Temperature = Number(s1 + \".\" + s2);\nreturn msg;","outputs":1,"initialize":"","finalize":"","x":800,"y":660,"wires":[["848663a0.c0b31"]]}]
1 Like

@Steve-Mcl

That is working great, many thanks for the prompt reply and working solution.

Now time for me to get this data onto the MQTT bus and into InfluxDB :slight_smile:

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