How merge two 16bit aray to one 32bit array and convert it to decadic number?

Hi all, i have two 16bit value (low and high), examle...
image
... and my test in NODE-RED...

[{"id":"998d1c8d77d1c262","type":"tab","label":"Flow 3","disabled":false,"info":"","env":[]},{"id":"0d4562672e72a699","type":"change","z":"998d1c8d77d1c262","name":"set msg.topic high_16bit","rules":[{"t":"set","p":"topic","pt":"msg","to":"high_16bit","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":260,"wires":[["f2e341d0529a80d9","c3f0ac1e66d4267a"]]},{"id":"86e035c36001da9e","type":"debug","z":"998d1c8d77d1c262","name":"debug1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1140,"y":140,"wires":[]},{"id":"ed7ee0155b5a72c7","type":"inject","z":"998d1c8d77d1c262","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"37856","payloadType":"num","x":130,"y":80,"wires":[["b016a2cbe96c62f0"]]},{"id":"eec4db9b805bbdcc","type":"inject","z":"998d1c8d77d1c262","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"4","payloadType":"num","x":130,"y":260,"wires":[["9d8518ca331c63c0"]]},{"id":"58da88f50bebf80a","type":"debug","z":"998d1c8d77d1c262","name":"low_16bit","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":960,"y":80,"wires":[]},{"id":"f2e341d0529a80d9","type":"debug","z":"998d1c8d77d1c262","name":"high_16bit","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":970,"y":280,"wires":[]},{"id":"b016a2cbe96c62f0","type":"bit-simple-sixteen","z":"998d1c8d77d1c262","name":"","x":330,"y":80,"wires":[["f5bc9c446dfde4f3"]]},{"id":"9ddacc4a31cc8a9c","type":"change","z":"998d1c8d77d1c262","name":"set msg.topic low_16bit","rules":[{"t":"set","p":"topic","pt":"msg","to":"low_16bit","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":80,"wires":[["58da88f50bebf80a","c3f0ac1e66d4267a"]]},{"id":"7acb1f6eb7102a36","type":"bit-simple-sixteen","z":"998d1c8d77d1c262","name":"","x":330,"y":160,"wires":[["16cbbf13e4c4c8f4"]]},{"id":"f5bc9c446dfde4f3","type":"buffer-parser","z":"998d1c8d77d1c262","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int16be","name":"item","offset":0,"length":16,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"","resultType":"value","resultTypeType":"","multipleResult":true,"fanOutMultipleResult":false,"setTopic":false,"outputs":1,"x":510,"y":80,"wires":[["9ddacc4a31cc8a9c"]]},{"id":"16cbbf13e4c4c8f4","type":"buffer-parser","z":"998d1c8d77d1c262","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int16be","name":"item","offset":0,"length":16,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"","resultType":"value","resultTypeType":"","multipleResult":true,"fanOutMultipleResult":false,"setTopic":false,"outputs":1,"x":510,"y":160,"wires":[["0d4562672e72a699"]]},{"id":"c3f0ac1e66d4267a","type":"join","z":"998d1c8d77d1c262","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"high_16bit","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":950,"y":140,"wires":[["86e035c36001da9e","c75ce0dcf35a740c"]]},{"id":"9d8518ca331c63c0","type":"delay","z":"998d1c8d77d1c262","name":"","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":330,"y":260,"wires":[["7acb1f6eb7102a36"]]},{"id":"900f2ac6a0e9ca6d","type":"inject","z":"998d1c8d77d1c262","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"37979","payloadType":"num","x":130,"y":120,"wires":[["b016a2cbe96c62f0"]]},{"id":"7ea2de4218819631","type":"inject","z":"998d1c8d77d1c262","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"38102","payloadType":"num","x":130,"y":160,"wires":[["b016a2cbe96c62f0"]]},{"id":"c75ce0dcf35a740c","type":"buffer-maker","z":"998d1c8d77d1c262","name":"","specification":"spec","specificationType":"ui","items":[{"name":"item1","type":"int16be","length":1,"dataType":"msg","data":"payload[0]"},{"name":"item2","type":"int16be","length":1,"dataType":"msg","data":"payload[1]"}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","x":970,"y":220,"wires":[["0d3d5731c628bfe8"]]},{"id":"0d3d5731c628bfe8","type":"debug","z":"998d1c8d77d1c262","name":"debug_fin","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1140,"y":220,"wires":[]}]

How to correctly convert to one 32 bit number and display it in decimal?
Thank you all in advance for the information.

Hi Josef

Sorry if this comes across a little mean - but looking at your flows and what you are doing, I suspect you are either a bit new to Node-RED and/or a bit new to binary data manipulation?

So rather than tell you where you went wrong I have made 3 demos for you to help you grasp the concepts.

Demo 1 - fixing your original flow...

chrome_Y7B9BLxpGS

Demo 2 - A little bit more realistic situation..

chrome_B5MYbqxJDP

Demo 3 - A more usual requirement (parsing Serial or TCP/UDP data strings)...

chrome_hz33LFXYHe

Full demo flow:

[{"id":"86e035c36001da9e","type":"debug","z":"998d1c8d77d1c262","name":"result","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1030,"y":160,"wires":[]},{"id":"ed7ee0155b5a72c7","type":"inject","z":"998d1c8d77d1c262","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"37856","payloadType":"num","x":130,"y":80,"wires":[["81a9923889dba303"]]},{"id":"eec4db9b805bbdcc","type":"inject","z":"998d1c8d77d1c262","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"4","payloadType":"num","x":130,"y":260,"wires":[["9d8518ca331c63c0"]]},{"id":"58da88f50bebf80a","type":"debug","z":"998d1c8d77d1c262","name":"low_16bit","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":760,"y":80,"wires":[]},{"id":"f2e341d0529a80d9","type":"debug","z":"998d1c8d77d1c262","name":"high_16bit","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":770,"y":260,"wires":[]},{"id":"f5bc9c446dfde4f3","type":"buffer-parser","z":"998d1c8d77d1c262","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"uint16be","name":"low_16bit","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"","resultType":"value","resultTypeType":"","multipleResult":true,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":470,"y":80,"wires":[["58da88f50bebf80a","c3f0ac1e66d4267a"]]},{"id":"16cbbf13e4c4c8f4","type":"buffer-parser","z":"998d1c8d77d1c262","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"uint16be","name":"high_16bit","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"","resultType":"value","resultTypeType":"","multipleResult":true,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":570,"y":260,"wires":[["f2e341d0529a80d9","c3f0ac1e66d4267a"]]},{"id":"c3f0ac1e66d4267a","type":"join","z":"998d1c8d77d1c262","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":550,"y":160,"wires":[["e18764df74ce07b2"]]},{"id":"9d8518ca331c63c0","type":"delay","z":"998d1c8d77d1c262","name":"","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":270,"y":260,"wires":[["1a7f584e7bb57741"]]},{"id":"900f2ac6a0e9ca6d","type":"inject","z":"998d1c8d77d1c262","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"37979","payloadType":"num","x":130,"y":120,"wires":[["81a9923889dba303"]]},{"id":"7ea2de4218819631","type":"inject","z":"998d1c8d77d1c262","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"38102","payloadType":"num","x":130,"y":160,"wires":[["81a9923889dba303"]]},{"id":"81a9923889dba303","type":"buffer-maker","z":"998d1c8d77d1c262","name":"to Buffer","specification":"spec","specificationType":"ui","items":[{"name":"item1","type":"uint16be","length":1,"dataType":"msg","data":"payload"}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","x":300,"y":80,"wires":[["f5bc9c446dfde4f3"]]},{"id":"e18764df74ce07b2","type":"buffer-maker","z":"998d1c8d77d1c262","name":"to Buffer","specification":"spec","specificationType":"ui","items":[{"name":"item1","type":"uint16be","length":1,"dataType":"msg","data":"payload.high_16bit"},{"name":"item2","type":"uint16be","length":1,"dataType":"msg","data":"payload.low_16bit"}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","x":700,"y":160,"wires":[["4a6757cbe25520b4"]]},{"id":"4a6757cbe25520b4","type":"buffer-parser","z":"998d1c8d77d1c262","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"uint32be","name":"result","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"","resultType":"value","resultTypeType":"","multipleResult":true,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":870,"y":160,"wires":[["86e035c36001da9e"]]},{"id":"1a7f584e7bb57741","type":"buffer-maker","z":"998d1c8d77d1c262","name":"to Buffer","specification":"spec","specificationType":"ui","items":[{"name":"item1","type":"uint16be","length":1,"dataType":"msg","data":"payload"}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","x":420,"y":260,"wires":[["16cbbf13e4c4c8f4"]]},{"id":"dfa37ff3aeb52b5d","type":"debug","z":"998d1c8d77d1c262","name":"result","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":910,"y":500,"wires":[]},{"id":"f73c5d788c6d9ed5","type":"inject","z":"998d1c8d77d1c262","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"93E0","payloadType":"str","x":130,"y":420,"wires":[["4f6f73a0ce45cc42"]]},{"id":"0b9037e80dd73895","type":"inject","z":"998d1c8d77d1c262","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0004","payloadType":"str","x":130,"y":600,"wires":[["49a37da2e9f30ede"]]},{"id":"8ef2b77c9c116a08","type":"join","z":"998d1c8d77d1c262","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":430,"y":500,"wires":[["fddfae3231fe2335"]]},{"id":"49a37da2e9f30ede","type":"delay","z":"998d1c8d77d1c262","name":"","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":270,"y":600,"wires":[["272673f0701fc3bb"]]},{"id":"36d87bc4514f55a3","type":"buffer-parser","z":"998d1c8d77d1c262","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"uint32be","name":"result","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"","resultType":"value","resultTypeType":"","multipleResult":true,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":750,"y":500,"wires":[["dfa37ff3aeb52b5d"]]},{"id":"4f6f73a0ce45cc42","type":"change","z":"998d1c8d77d1c262","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"low","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":420,"wires":[["8ef2b77c9c116a08"]]},{"id":"8e05e5e0089fab6b","type":"inject","z":"998d1c8d77d1c262","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"945B","payloadType":"str","x":130,"y":460,"wires":[["4f6f73a0ce45cc42"]]},{"id":"ee363299df1cfda8","type":"inject","z":"998d1c8d77d1c262","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"94D6","payloadType":"str","x":130,"y":500,"wires":[["4f6f73a0ce45cc42"]]},{"id":"272673f0701fc3bb","type":"change","z":"998d1c8d77d1c262","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"high","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":600,"wires":[["8ef2b77c9c116a08"]]},{"id":"fddfae3231fe2335","type":"function","z":"998d1c8d77d1c262","name":"high & low","func":"msg.payload = msg.payload.high + msg.payload.low\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":590,"y":500,"wires":[["36d87bc4514f55a3"]]},{"id":"d8ce3df723be4f19","type":"comment","z":"998d1c8d77d1c262","name":"Continueing in the same way you started","info":"","x":220,"y":40,"wires":[]},{"id":"6658c40747aac26f","type":"comment","z":"998d1c8d77d1c262","name":"More likely scenario - you get 2 strings (e.g. 93E0 followed by 0004)","info":"","x":300,"y":380,"wires":[]},{"id":"3a5922d621c85743","type":"debug","z":"998d1c8d77d1c262","name":"result","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":610,"y":800,"wires":[]},{"id":"0c1d92f22c9ceb26","type":"inject","z":"998d1c8d77d1c262","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"03000493E0FF0D","payloadType":"str","x":170,"y":760,"wires":[["062f447e3cad0c02"]]},{"id":"062f447e3cad0c02","type":"buffer-parser","z":"998d1c8d77d1c262","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"byte","name":"startMarker","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint32be","name":"data","offset":1,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"byte","name":"CRC","offset":5,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"byte","name":"endMarker","offset":6,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"","resultType":"keyvalue","resultTypeType":"","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":430,"y":800,"wires":[["3a5922d621c85743"]]},{"id":"1d1993c915bf7138","type":"inject","z":"998d1c8d77d1c262","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"030004945BFF0D","payloadType":"str","x":170,"y":800,"wires":[["062f447e3cad0c02"]]},{"id":"2ecc43de14e9b4c5","type":"inject","z":"998d1c8d77d1c262","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"03000494D6FF0D","payloadType":"str","x":170,"y":840,"wires":[["062f447e3cad0c02"]]},{"id":"b21ee408897aa19b","type":"comment","z":"998d1c8d77d1c262","name":"More realistic scenario - you get a string of data from a serial or TCP device","info":"","x":320,"y":720,"wires":[]}]

Hope that helps.

Yes, I'm a beginner.
Thank you very much.
The variant "Continuing in the same way you started" is exactly what I need.
Thank you very much again.

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