# Modbus TCP float to value

**URL:** <https://discourse.nodered.org/t/modbus-tcp-float-to-value/58393>\
**Category:** General\
**Created:** [15 February 2022 14:18 UTC](https://discourse.nodered.org/t/modbus-tcp-float-to-value/58393 "2022-02-15T14:18:27Z")\
**Posts on this page:** 1\
**Showing post:** 35

<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:** [16 February 2022 15:07 UTC](https://discourse.nodered.org/t/modbus-tcp-float-to-value/58393/35 "2022-02-16T15:07:31Z")

</div>

that was the data I needed.

So, my point was to demonstrate how you get all the values in one go and convert them to the right format.

Demo...

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

Demo flow (import using CTRL+I)

```auto
[{"id":"36222b89d1539d62","type":"inject","z":"150d20998fc7fe72","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1980,"y":200,"wires":[["52e1a776e983b3f8"]]},{"id":"52e1a776e983b3f8","type":"function","z":"150d20998fc7fe72","name":"fake modbus data","func":"\nmsg = {\n \"topic\": \"polling\",\n \"payload\": [\n 1432,\n 17256,\n 64922,\n 17255,\n 63669,\n 15958,\n 46993,\n 15878,\n 8440,\n 16007,\n 35711,\n 15951,\n 8520,\n 17256,\n 6466,\n 17256\n],\n \"responseBuffer\": {\n \"data\": [\n 1432,\n 17256,\n 64922,\n 17255,\n 63669,\n 15958,\n 46993,\n 15878,\n 8440,\n 16007,\n 35711,\n 15951,\n 8520,\n 17256,\n 6466,\n 17256\n],\n \"buffer\": Buffer.from([\n 5,\n 152,\n 67,\n 104,\n 253,\n 154,\n 67,\n 103,\n 248,\n 181,\n 62,\n 86,\n 183,\n 145,\n 62,\n 6,\n 32,\n 248,\n 62,\n 135,\n 139,\n 127,\n 62,\n 79,\n 33,\n 72,\n 67,\n 104,\n 25,\n 66,\n 67,\n 104\n])\n },\n \"input\": {\n \"topic\": \"polling\",\n \"from\": \"\",\n \"payload\": {\n \"unitid\": \"61\",\n \"fc\": 3,\n \"address\": \"0\",\n \"quantity\": \"16\",\n \"messageId\": \"620cebbcc893dad1cfa8649e\"\n },\n \"queueLengthByUnitId\": {\n \"unitId\": 61,\n \"queueLength\": 0\n },\n \"queueUnitId\": 61,\n \"unitId\": 61\n }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2055.5555572509766,"y":245.55552864074707,"wires":[["a80bc70fb3ddbe19","c53f4232eb527410"]]},{"id":"a80bc70fb3ddbe19","type":"debug","z":"150d20998fc7fe72","name":"modbus data","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2255.5555572509766,"y":245.55552864074707,"wires":[]},{"id":"c53f4232eb527410","type":"buffer-parser","z":"150d20998fc7fe72","name":"","data":"responseBuffer.buffer","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"floatle","name":"L1_RMS_V","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"L1_RMS_FV","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"L2_RMS_V","offset":8,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"L2_RMS_FV","offset":12,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"L3_RMS_V","offset":16,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"L3_RMS_FV","offset":20,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"L1L2_RMS_V","offset":24,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"L1L2_RMS_FV","offset":28,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"swap16","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"return","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":2075.5555572509766,"y":325.55552864074707,"wires":[["70cca1b71057c8e0"]]},{"id":"70cca1b71057c8e0","type":"debug","z":"150d20998fc7fe72","name":"parsed data","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2255.5555572509766,"y":325.55552864074707,"wires":[]}]

```

---

_[View the full topic](https://discourse.nodered.org/t/modbus-tcp-float-to-value/58393)._
