# Modbus TCP variable split function code

**URL:** <https://discourse.nodered.org/t/modbus-tcp-variable-split-function-code/30684>\
**Category:** General\
**Created:** [25 July 2020 08:54 UTC](https://discourse.nodered.org/t/modbus-tcp-variable-split-function-code/30684 "2020-07-25T08:54:38Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [25 July 2020 09:34 UTC](https://discourse.nodered.org/t/modbus-tcp-variable-split-function-code/30684/2 "2020-07-25T09:34:13Z")

</div>

one method - try this [[Announce] node-red-contrib-buffer-parser - V2.0.2](https://discourse.nodered.org/t/announce-node-red-contrib-buffer-parser-v2-0-2/25879)

The buffer parser takes your array of data & turns it into named items of any format you need (float, signed integer, byte revered if necessary (often necessary with modbus))...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/5/e5421495927650131971930642a92f6fa4b4907c.png)

then you can access each named items value like this

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/f/3f037018aa00b7a4b9e98b0104e87223399d82b0.png)

then paste that into the dashboard items like this...  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/1/913e2ddfd5a6763eb8f67bfeff40d5ef31509158.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/6/b67a06ef6bd434ae9c62fb2d28d686f5d4ac25ea.png)

demo flow...

```auto
[{"id":"68dcb361.27d5bc","type":"buffer-parser","z":"284fa9c6.f473c6","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int16be","name":"item1","offset":"0","length":"1","offsetbit":"0","mask":""},{"type":"int16be","name":"item2","offset":"2","length":"1","offsetbit":"0","mask":""},{"type":"int16be","name":"item3","offset":"4","length":"1","offsetbit":"0","mask":""},{"type":"int16be","name":"item4","offset":"6","length":"1","offsetbit":"0","mask":""},{"type":"int16be","name":"item5","offset":"8","length":"1","offsetbit":"0","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"object","resultTypeType":"output","multipleResult":false,"setTopic":true,"x":700,"y":540,"wires":[["ad8c8500.89fdd8","801b9f08.c2dcd","fa47c578.c6fdd8"]]},{"id":"5ad37cbb.990974","type":"inject","z":"284fa9c6.f473c6","name":"fake data","topic":"fake data","payload":"[12345,543321,31314,44444,71111,15243,43434,999]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":520,"y":540,"wires":[["68dcb361.27d5bc"]]},{"id":"ad8c8500.89fdd8","type":"debug","z":"284fa9c6.f473c6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":870,"y":540,"wires":[]},{"id":"801b9f08.c2dcd","type":"ui_text","z":"284fa9c6.f473c6","group":"9ff3d14a.12719","order":0,"width":0,"height":0,"name":"","label":"text","format":"{{payload.item1.value}}","layout":"row-spread","x":830,"y":640,"wires":[]},{"id":"fa47c578.c6fdd8","type":"ui_text","z":"284fa9c6.f473c6","group":"9ff3d14a.12719","order":1,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload.item2.value}}","layout":"row-spread","x":830,"y":680,"wires":[]},{"id":"9ff3d14a.12719","type":"ui_group","z":"","name":"Default","tab":"93ef5e6b.7382d","order":1,"disp":true,"width":"6","collapse":false},{"id":"93ef5e6b.7382d","type":"ui_tab","z":"","name":"STUFF","icon":"dashboard","disabled":false,"hidden":false}]

```

---

_[View the full topic](https://discourse.nodered.org/t/modbus-tcp-variable-split-function-code/30684)._
