# Modbus 32 Bit Float to an INT

**URL:** <https://discourse.nodered.org/t/modbus-32-bit-float-to-an-int/64854>\
**Category:** Industrial\
**Created:** [8 July 2022 17:22 UTC](https://discourse.nodered.org/t/modbus-32-bit-float-to-an-int/64854 "2022-07-08T17:22:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bceyresy](https://avatars.discourse-cdn.com/v4/letter/b/7c8e57/32.png) [@bceyresy](https://discourse.nodered.org/u/bceyresy)\
**Post date:** [8 July 2022 17:22 UTC](https://discourse.nodered.org/t/modbus-32-bit-float-to-an-int/64854/1 "2022-07-08T17:22:44Z")

</div>

Hi,

I have a power meter which I am pulling readings from via Modbus TCP. The data is in float & I need to put the 2 registers together then convert it to an integer.

just a note, I had to click the data in the array to toggle to Hex values.

Please can someone help on the best way around this.

 ![Screenshot 2022-07-08 at 18.16.37](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/2/52912d7fb851f9dd591c59ddb6fd42c4a6221b45.jpeg)  
 ![Screenshot 2022-07-08 at 18.16.48](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/7/b790adee5e35d17b2b070c02d289132645f81e86.jpeg)

please see screen shots.

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [8 July 2022 17:49 UTC](https://discourse.nodered.org/t/modbus-32-bit-float-to-an-int/64854/2 "2022-07-08T17:49:01Z")

</div>

Hello ..

you can use the [node-red-contrib-buffer-parser](https://flows.nodered.org/node/node-red-contrib-buffer-parser) node to do the conversion to float

**Example Flow**

```auto
[{"id":"2b690201c6ec9725","type":"function","z":"ee297f7b.69fda","name":"modbus fake data","func":"\nmsg.payload = Buffer.from([0x43, 0x74, 0x27, 0x0C])\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":470,"y":840,"wires":[["0dafbe21373e14c5","62ecced6b754b480"]]},{"id":"60815d2eb8942be6","type":"inject","z":"ee297f7b.69fda","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":280,"y":840,"wires":[["2b690201c6ec9725"]]},{"id":"dfb04119cbbb73a8","type":"debug","z":"ee297f7b.69fda","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":900,"y":840,"wires":[]},{"id":"0dafbe21373e14c5","type":"buffer-parser","z":"ee297f7b.69fda","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"floatbe","name":"item1","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","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":710,"y":840,"wires":[["dfb04119cbbb73a8"]]},{"id":"62ecced6b754b480","type":"debug","z":"ee297f7b.69fda","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":600,"y":760,"wires":[]}]

```

If you wire the top modbus output to Buffer parser, the actual buffer will be in

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

So set that msg Property in the node's config instead of `msg.payload`

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

---

<div class="post-metadata">

**Author:** ![bceyresy](https://avatars.discourse-cdn.com/v4/letter/b/7c8e57/32.png) [@bceyresy](https://discourse.nodered.org/u/bceyresy)\
**Post date:** [20 July 2022 11:50 UTC](https://discourse.nodered.org/t/modbus-32-bit-float-to-an-int/64854/3 "2022-07-20T11:50:43Z")

</div>

Thanks so much. What a great little tool. Much appreciated 👍

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [3 August 2022 11:51 UTC](https://discourse.nodered.org/t/modbus-32-bit-float-to-an-int/64854/4 "2022-08-03T11:51:18Z")

</div>

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