# Modbus UINT16 to decimal?

**URL:** <https://discourse.nodered.org/t/modbus-uint16-to-decimal/80498>\
**Category:** General\
**Tags:** modbus\
**Created:** [11 August 2023 13:20 UTC](https://discourse.nodered.org/t/modbus-uint16-to-decimal/80498 "2023-08-11T13:20:02Z")\
**Posts on this page:** 16\
**Page:** 2

<div class="post-metadata">

**Author:** ![Darren](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/darren/32/92202_2.png) [@Darren](https://discourse.nodered.org/u/Darren)\
**Post date:** [18 August 2023 09:12 UTC](https://discourse.nodered.org/t/modbus-uint16-to-decimal/80498/21 "2023-08-18T09:12:16Z")

</div>

So far, from the documentation, 2 words of 16 bits are used for a total of 32-bits are used to hold single-precision floating point numbers.

 ![mvreader_23_08_18_100628](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/f/1f701796490dfdec69d60e97814f42d1c9ff18ea.png)  
 ![mvreader_23_08_18_100704](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/c/bc065d0413eabab42f7f0a632128b336d4734dcf.png)

---

<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:** [18 August 2023 09:57 UTC](https://discourse.nodered.org/t/modbus-uint16-to-decimal/80498/22 "2023-08-18T09:57:46Z")

</div>

> [@Darren](#):
>
> So far, from the documentation, 2 words of 16 bits are used for a total of 32-bits are used to hold single-precision floating point numbers.

That is as expected.

BUT that does not mean whoever programmed the PLC used 32 bit data. They might have packed the float into an INT (i.e. it is possible and common for a PLC programmer to store `0.123` as `123` in a WD)

Assuming for a second you actually did a cross-reference on the PLC for this data & assuming you found they were being written to PLC memory via 32 bit functions (e.g. **FMOV (Floating Point Move)**, **FMUL (Floating Point Multiply):**, **DMOV (Double Word Move)** etc) then you need to adjust your ModBus reads as you are only reading / providing 1 WD of data in your example...

> [@Darren](#):
>
> |Expected value|Modbus|
> 
> |0.165|{"data":[41496],"buffer":[162,24]}|

Modbus values are 16 bit. [41496] is 1 WD (2 bytes) - i.e. not enough data to build a Float value.

* * *

Your ModBus requests, for float values SHOULD be set to a length of 2.  
Remember, 2 UINT16s (aka 2 WORD, aka 4 bytes, aka 32 bits)

In short, your problems begin at the fact you are attempting to compute a float value with only half of the data.

---

<div class="post-metadata">

**Author:** ![Darren](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/darren/32/92202_2.png) [@Darren](https://discourse.nodered.org/u/Darren)\
**Post date:** [18 August 2023 13:47 UTC](https://discourse.nodered.org/t/modbus-uint16-to-decimal/80498/23 "2023-08-18T13:47:43Z")

</div>

Currently I'm trying to follow the following guides to read 32bit values:

- [How to Use Node-Red with Modbus](https://stevesnoderedguide.com/node-red-modbus)
- [Modbus,Node-Red and MQTT- Video 2](https://www.youtube.com/watch?v=YAvSJrp4lq0)

We could do some multiplication PLC-side, but would prefer to avoid reprogramming it.

EDIT: I'm now using the following flow:

```auto
[
    {
        "id": "5e0f1cacf0774214",
        "type": "inject",
        "z": "85dc5731.881ef8",
        "name": "gfuel_flow_rate",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "10",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "gfuel_flow_rate",
        "payload": "",
        "payloadType": "date",
        "x": 360,
        "y": 620,
        "wires": [
            [
                "fb2ca1bab7230577",
                "1682d736eb4b5782",
                "894ca54d5d0e3e64"
            ]
        ]
    },
    {
        "id": "1682d736eb4b5782",
        "type": "debug",
        "z": "85dc5731.881ef8",
        "name": "debug 8",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 560,
        "y": 620,
        "wires": []
    },
    {
        "id": "894ca54d5d0e3e64",
        "type": "function",
        "z": "85dc5731.881ef8",
        "name": "Input 32bit float",
        "func": "//src: https://www.youtube.com/watch?v=YAvSJrp4lq0\nvar fc = 3;\nvar sa = 106;\nvar addresses = 2;\nvar slave_ip = msg.payload.slave_ip;\n//msg.slave_ip = \"192.168.1.31\";\nmsg.payload = { value: msg.payload, 'fc': fc, 'unitid': 1, 'address': sa, 'quantity': addresses };\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 680,
        "y": 560,
        "wires": [
            [
                "fd8499e0ba5275c3"
            ]
        ]
    },
    {
        "id": "fd8499e0ba5275c3",
        "type": "modbus-flex-getter",
        "z": "85dc5731.881ef8",
        "name": "",
        "showStatusActivities": false,
        "showErrors": false,
        "showWarnings": true,
        "logIOActivities": false,
        "server": "d8b07ddb.c44d4",
        "useIOFile": false,
        "ioFile": "",
        "useIOForPayload": false,
        "emptyMsgOnFail": false,
        "keepMsgProperties": false,
        "delayOnStart": false,
        "startDelayTime": "",
        "x": 850,
        "y": 660,
        "wires": [
            [],
            [
                "3df29f7242fe316c"
            ]
        ]
    },
    {
        "id": "3df29f7242fe316c",
        "type": "function",
        "z": "85dc5731.881ef8",
        "name": "Get 32bit float",
        "func": "// src: https://stevesnoderedguide.com/node-red-modbus\nconst buf = Buffer.from(msg.payload.buffer);\nconst value = buf.readFloatLE();\nmsg.value = value;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1020,
        "y": 580,
        "wires": [
            [
                "a7cca763971d2b3d"
            ]
        ]
    },
    {
        "id": "a7cca763971d2b3d",
        "type": "debug",
        "z": "85dc5731.881ef8",
        "name": "debug 12",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1200,
        "y": 580,
        "wires": []
    },
    {
        "id": "d8b07ddb.c44d4",
        "type": "modbus-client",
        "name": "Boiler_PLC",
        "clienttype": "tcp",
        "bufferCommands": true,
        "stateLogEnabled": false,
        "queueLogEnabled": false,
        "failureLogEnabled": false,
        "tcpHost": "192.168.127.2",
        "tcpPort": "502",
        "tcpType": "DEFAULT",
        "serialPort": "/dev/ttyUSB",
        "serialType": "RTU-BUFFERD",
        "serialBaudrate": "9600",
        "serialDatabits": "8",
        "serialStopbits": "1",
        "serialParity": "none",
        "serialConnectionDelay": "100",
        "serialAsciiResponseStartDelimiter": "",
        "unit_id": "1",
        "commandDelay": "1",
        "clientTimeout": "1000",
        "reconnectOnTimeout": true,
        "reconnectTimeout": "2000",
        "parallelUnitIdsAllowed": true
    }
]

```

to get data that looks like this:

```auto
{"data":[54006,15745],"buffer":[210,246,61,129]}

```

---

<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:** [18 August 2023 14:16 UTC](https://discourse.nodered.org/t/modbus-uint16-to-decimal/80498/24 "2023-08-18T14:16:56Z")

</div>

**Hold on**. There is no need for any PLC re-programming

Just answer the question: **Does the CURRENT PLC Ladder use 16 bit or 32 bit functions.**

If 16 bit, OK, no problem.  
If the PLC uses 32 bit values, you need to read a quantity of `2` from ModBus for each 32 bit value - otherwise, we are missing IMPORTANT parts of the data and we CANNOT compute the floating point value without all of the data!

As I have stated several times: ModBus reads in UINT16. But that does **NOT** mean you have to re-program the PLC. Just read MORE data from ModBus to get 2 UINT16s for every FLOAT. Then use buffer parser to convert the 2 x UINT16 back into a FLOAT or UINT32 or whatever it needs to be!

What part of this is not clear Darren? Please, tell me so I can improve my communication skills.

* * *

# Lets try to be ultra clear and precise...

If your PLC has a FLOAT value and it is stored in 2 WORDS (i.e. 32 bit) in PLC memory, then you MUST read both WORDS (quantity 2) from ModBus to get all of the necessary components of data so that you can re-create the Float.

What functions are used in the PLC to generate the numbers you are trying to read? Are the double WORD instructions like FMOV, FDIV, DMOV etc. OR. single WORD instructions e.g. DIV, MUL, MOV?

## In short...

### Where you said

> [@Darren](#):
>
> Understood now! Thank you! I will enter the data here:
> 
> | Expected value | Modbus |
> | --- | --- |
> | 0.165 | {"data":[41496],"buffer":[162,24]} |
> | 0.229 | {"data":[32108],"buffer":[125,108]} |
> | 0.201 | {"data":[56615],"buffer":[221,39]} |
> | 0.235 | {"data":[11439],"buffer":[44,175]} |
> | 0.228 | {"data":[52312],"buffer":[204,88]} |
> | 0.164 | {"data":[65061],"buffer":[254,37]} |
> | 0.228 | {"data":[7247],"buffer":[28,79]} |
> | 0.165 | {"data":[65061],"buffer":[254,37]} |
> | 0.164 | {"data":[60204],"buffer":[235,44]} |

### I expect to see 4 bytes for every FLOAT

| Expected value | Modbus |
| --- | --- |
| 0.165 | {data:[41496, ???],buffer:[162,24, ???, ???]} |
| 0.229 | {data:[32108, ???],buffer:[125,108, ???, ???]} |

_this assumes your PLC is using 2 WORD/32 bit values - but you still have NOT confirmed this_

---

<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:** [18 August 2023 14:36 UTC](https://discourse.nodered.org/t/modbus-uint16-to-decimal/80498/25 "2023-08-18T14:36:01Z")

</div>

> [@Darren](#):
>
> to get data that looks like this:
> 
> ```auto
> {"data":[54006,15745],"buffer":[210,246,61,129]}
> 
> ```

ok, I see you have now edited your post and are now getting 2 WORDS / 32 bit data

Good.

So what _should_ that equal? Remember, when I asked for data I also asked for what it _should_ be.

> [@Steve-Mcl](#):
>
> #### I need:
> 
> 1. The ACTUAL ModBus payload _(you did this when you copied the full payload value - great!)_
> 2. At the EXACT SAME TIME - I need the ACTUAL equivalent matching value from the PLC - so that I have both the source (ModBus) data AND a target value to achieve - so I can check my work and ensure you get accurate data.

Almost there 🤞

---

<div class="post-metadata">

**Author:** ![Darren](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/darren/32/92202_2.png) [@Darren](https://discourse.nodered.org/u/Darren)\
**Post date:** [18 August 2023 15:16 UTC](https://discourse.nodered.org/t/modbus-uint16-to-decimal/80498/26 "2023-08-18T15:16:56Z")

</div>

Here's new data (I'll have to post more next week, as the system is shutting down for the weekend):

| Expected | Modbus |
| --- | --- |
| 0.024 | {"data":[33154,15553],"buffer":[129,130,60,193]} |

---

<div class="post-metadata">

**Author:** ![Darren](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/darren/32/92202_2.png) [@Darren](https://discourse.nodered.org/u/Darren)\
**Post date:** [14 September 2023 14:48 UTC](https://discourse.nodered.org/t/modbus-uint16-to-decimal/80498/27 "2023-09-14T14:48:20Z")

</div>

I've been distracted with other work; finally had a chance to get some more data!

| Expected | Modbus |
| --- | --- |
| 0.150 | {"data":[19850,15897],"buffer":[77,138,62,25]} |
| 0.228 | {"data":[7247,15977],"buffer":[28,79,62,105]} |
| 0.183 | {"data":[53360,15931],"buffer":[208,112,62,59]} |
| 0.137 | {"data":[2037,15884],"buffer":[7,245,62,12]} |
| 0.193 | {"data":[42589,15941],"buffer":[166,93,62,69]} |
| 0.143 | {"data":[63073,15889],"buffer":[246,97,62,17]} |
| 0.149 | {"data":[455,15897],"buffer":[1,199,62,25]} |
| 0.229 | {"data":[32108,15978],"buffer":[125,108,62,106]} |

---

<div class="post-metadata">

**Author:** ![Darren](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/darren/32/92202_2.png) [@Darren](https://discourse.nodered.org/u/Darren)\
**Post date:** [15 September 2023 08:47 UTC](https://discourse.nodered.org/t/modbus-uint16-to-decimal/80498/28 "2023-09-15T08:47:38Z")

</div>

@Steve-Mcl Do those numbers look ok? I'm experimenting once again with variations in the buffer-parser, hopefully 32bit will produce some realistic numbers.

---

<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:** [15 September 2023 09:12 UTC](https://discourse.nodered.org/t/modbus-uint16-to-decimal/80498/29 "2023-09-15T09:12:07Z")

</div>

It has been too long for me to parse this all back into my head.

To give me a leg up, please update that table with register numbers and modbus unit numbers

e.g.

| expected | node-red data | register | unit id |
| --- | --- | --- | --- |
| 0.150 | {"data":[19850,15897],"buffer":[77,138,62,25]} | 1 & 2 | 0 |
| 0.228 | {"data":[7247,15977],"buffer":[28,79,62,105]} | 3 & 4 | 0 |
| 0.183 | {data:[53360,15931],buffer:[208,112,62,59]} | 5 & 6 | etc |
| 0.137 | {data:[2037,15884],buffer:[7,245,62,12]} | etc | etc |
| 0.193 | {data:[42589,15941],buffer:[166,93,62,69]} | etc | etc |
| 0.143 | {data:[63073,15889],buffer:[246,97,62,17]} | etc | etc |
| 0.149 | {data:[455,15897],buffer:[1,199,62,25]} | etc | etc |
| 0.229 | {data:[32108,15978],buffer:[125,108,62,106]} | etc | etc |

---

<div class="post-metadata">

**Author:** ![Darren](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/darren/32/92202_2.png) [@Darren](https://discourse.nodered.org/u/Darren)\
**Post date:** [15 September 2023 09:35 UTC](https://discourse.nodered.org/t/modbus-uint16-to-decimal/80498/30 "2023-09-15T09:35:03Z")

</div>

WIP:

| Expected | Modbus | Register | Unit ID |
| --- | --- | --- | --- |
| 0.024 | {"data":[33154,15553],"buffer":[129,130,60,193]} | 106 | 1 |
| 0.150 | {"data":[19850,15897],"buffer":[77,138,62,25]} | 106 | 1 |
| 0.228 | {"data":[7247,15977],"buffer":[28,79,62,105]} | 106 | 1 |
| 0.183 | {"data":[53360,15931],"buffer":[208,112,62,59]} | 106 | 1 |
| 0.137 | {"data":[2037,15884],"buffer":[7,245,62,12]} | 106 | 1 |
| 0.193 | {"data":[42589,15941],"buffer":[166,93,62,69]} | 106 | 1 |
| 0.143 | {"data":[63073,15889],"buffer":[246,97,62,17]} | 106 | 1 |
| 0.149 | {"data":[455,15897],"buffer":[1,199,62,25]} | 106 | 1 |
| 0.229 | {"data":[32108,15978],"buffer":[125,108,62,106]} | 106 | 1 |

Unless I've become completely confused, it looks like it's the same register and unit ID for them all:

 ![msedge_23_09_15_103039](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/f/4f5f450d02dc3d3098249b4edbd2df104d001f12.png)  
 ![GXW3_23_09_15_103629](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/7/d7ffbcad8bd0f7332886d82c33f1fc3719df27e0.png)

Code:

### Input 32bit float

```auto
//src: https://www.youtube.com/watch?v=YAvSJrp4lq0
var fc = 3;
var sa = 106;
var addresses = 2;
var slave_ip = msg.payload.slave_ip;
//msg.slave_ip = "192.168.1.31";
msg.payload = { value: msg.payload, 'fc': fc, 'unitid': 1, 'address': sa, 'quantity': addresses };
return msg;

```

### Modbus Flex Getter

standard, connection to PLC

### Get 32bit float

```auto
// src: https://stevesnoderedguide.com/node-red-modbus
const buf = Buffer.from(msg.payload.buffer);
const value = buf.readFloatLE();
msg.value = value;
return msg;

```

Thank you for your help, Steve!!!

---

<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:** [15 September 2023 09:48 UTC](https://discourse.nodered.org/t/modbus-uint16-to-decimal/80498/31 "2023-09-15T09:48:28Z")

</div>

I cannot make head nor tail of your data. There is absolutely no pattern whatsoever. Its like the first sample value is an LE (little endian) number, the 2nd is a BE (big endian) number and the third makes no sense whatsoever.

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

  

Looking at your flow screenshot - I suspect there is some shenanigans going on BEFORE your debug node - when I asked for the output of the Modbus node mean DIRECTLY (untouched, unspoiled)

_Either that or Register `106` is not lined up to what you think it is in the PLC_

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

Can you grab the data once more (directly from Modbus as shown above) and list a few samples with "expect value" & "Node-RED debug value" please?

* * *

**Question** : Since this is Mitsubishi, cant you use the MC-Protocol nodes instead? Much easier and you dont have the whole address remapping from Modbus address space to Mitsubishi native address space to deal with!

---

<div class="post-metadata">

**Author:** ![Darren](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/darren/32/92202_2.png) [@Darren](https://discourse.nodered.org/u/Darren)\
**Post date:** [15 September 2023 11:23 UTC](https://discourse.nodered.org/t/modbus-uint16-to-decimal/80498/32 "2023-09-15T11:23:35Z")

</div>

Direct readings (Register D106, Unit ID: 1):

| Expected | Direct Modbus |
| --- | --- |
| 0.166 | {"data":[29258,15914],"buffer":[114,74,62,42]} |
| 0.165 | {"data":[41496,15912],"buffer":[162,24,62,40]} |
| 0.182 | {"data":[32012,15930],"buffer":[125,12,62,58]} |
| 0.229 | {"data":[65061,15912],"buffer":[254,37,62,40]} |
| 0.141 | {"data":[24066,15888],"buffer":[94,2,62,16]} |
| 0.153 | {"data":[41652,15900],"buffer":[162,180,62,28]} |
| 0.230 | {"data":[12173,15979],"buffer":[47,141,62,107]} |

---

<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:** [15 September 2023 11:58 UTC](https://discourse.nodered.org/t/modbus-uint16-to-decimal/80498/33 "2023-09-15T11:58:19Z")

</div>

Again, those number vary so wildly, there is something wrong.

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

Perhaps REG 106 is NOT pointing to the address in the PLC you think it is.

Perhaps, you have an "off by one" error (e.g. you should be reading REG 105)

1. Show me the actual D values in the PLC memory view.
2. Show me the mapping setup for Modbus (i.e. how did you come to Modbus REG 106? What do you think it points to in the PLC?)
3. Answer my QUESTION from previous post

---

<div class="post-metadata">

**Author:** ![Darren](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/darren/32/92202_2.png) [@Darren](https://discourse.nodered.org/u/Darren)\
**Post date:** [18 September 2023 10:07 UTC](https://discourse.nodered.org/t/modbus-uint16-to-decimal/80498/34 "2023-09-18T10:07:59Z")

</div>

1. 

 ![Paneltech memory](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/c/4c291fc049ff25331731ace67eff3eebf196720e.png)

1. The strange thing is, we always get the same garbage per sensible number; I have observed them to match up (any errors would be down to human reaction times copying the log). I cross-referenced the values, and direct from the Modbus Flex Getter or after "Get 32bit float" values are the same, i.e. both previous tables have equally valid data.

We get the PLC memory address D106 from XML exported from GXWorks3:

```auto
          <variable name="gfuel_flow_rate" address="D106">
            <type>
              <REAL />
            </type>
            <addData>
              <data name="http://www.mitsubishielectric.com/xml/variableLineNumber" handleUnknown="implementation">
                <variableLineNumber number="3" />
              </data>
            </addData>
          </variable>

```

1. Regarding MC-Protocol, we typically prefer Modbus for code portability. We export an XML from the GXWorks3 program of all the device labels, which we then push through a Modbus getters to use to filter the connected devices into individual dials and grab the data. It works for 99% of the other sensors, even this particular type of rotation sensor with exactly the same program elsewhere. We also sometimes use cheaper non-Mitsubishi PLCs or need to communicate with 3rd party equipment, for which we're obliged to use Modbus. I will give the MC-Protocol nodes a go, hopefully won't have to reprogram the PLC too much for that.

### Solution

PS. I got it working - after comparing with another working legacy program we had, turns out I was trying to read a data array when all I needed was the second number from `data`, e.g. for `{"data":[53360,15931],"buffer":[208,112,62,59]}`, all I needed was `15931` and put it through buffer parser  
to read `msg.payload.buffer`, byte swap 16, float LE, and I get sensible numbers that match up with GXWorks3

Flow:

```auto
[
    {
        "id": "5e0f1cacf0774214",
        "type": "inject",
        "z": "85dc5731.881ef8",
        "name": "gfuel_flow_rate",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "10",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "gfuel_flow_rate",
        "payload": "",
        "payloadType": "date",
        "x": 360,
        "y": 620,
        "wires": [
            [
                "fb2ca1bab7230577",
                "1682d736eb4b5782",
                "894ca54d5d0e3e64"
            ]
        ]
    },
    {
        "id": "1682d736eb4b5782",
        "type": "debug",
        "z": "85dc5731.881ef8",
        "name": "debug 8",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 560,
        "y": 620,
        "wires": []
    },
    {
        "id": "894ca54d5d0e3e64",
        "type": "function",
        "z": "85dc5731.881ef8",
        "name": "Input 32bit float",
        "func": "//src: https://www.youtube.com/watch?v=YAvSJrp4lq0\nvar fc = 3;\nvar sa = 106;\nvar addresses = 2;\nvar slave_ip = msg.payload.slave_ip;\n//msg.slave_ip = \"192.168.1.31\";\nmsg.payload = { value: msg.payload, 'fc': fc, 'unitid': 1, 'address': sa, 'quantity': addresses };\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 680,
        "y": 560,
        "wires": [
            [
                "fd8499e0ba5275c3"
            ]
        ]
    },
    {
        "id": "fd8499e0ba5275c3",
        "type": "modbus-flex-getter",
        "z": "85dc5731.881ef8",
        "name": "",
        "showStatusActivities": false,
        "showErrors": false,
        "showWarnings": true,
        "logIOActivities": false,
        "server": "d8b07ddb.c44d4",
        "useIOFile": false,
        "ioFile": "",
        "useIOForPayload": false,
        "emptyMsgOnFail": false,
        "keepMsgProperties": false,
        "delayOnStart": false,
        "startDelayTime": "",
        "x": 850,
        "y": 660,
        "wires": [
            [],
            [
                "3df29f7242fe316c",
                "298d7c567c6bad3f"
            ]
        ]
    },
    {
        "id": "298d7c567c6bad3f",
        "type": "debug",
        "z": "85dc5731.881ef8",
        "name": "debug 13",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1080,
        "y": 660,
        "wires": []
    },
    {
        "id": "3df29f7242fe316c",
        "type": "function",
        "z": "85dc5731.881ef8",
        "name": "Get 32bit float",
        "func": "// src: https://stevesnoderedguide.com/node-red-modbus\nconst buf = Buffer.from(msg.payload.buffer);\nconst value = buf.readFloatLE();\nmsg.value = value;\nmsg.value = msg.value[1];\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1020,
        "y": 580,
        "wires": [
            [
                "a7cca763971d2b3d",
                "b251a56754b03ef8"
            ]
        ]
    },
    {
        "id": "b251a56754b03ef8",
        "type": "buffer-parser",
        "z": "85dc5731.881ef8",
        "name": "",
        "data": "payload.buffer",
        "dataType": "msg",
        "specification": "spec",
        "specificationType": "ui",
        "items": [
            {
                "type": "floatle",
                "name": "item1",
                "offset": 0,
                "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": 1190,
        "y": 420,
        "wires": [
            [
                "992482cf6db63c1f",
                "4845ee5fdce680bb"
            ]
        ]
    },
    {
        "id": "992482cf6db63c1f",
        "type": "function",
        "z": "85dc5731.881ef8",
        "name": "Strip Item",
        "func": "var num = msg.payload[\"item1\"];\nmsg.payload = Math.round((num + Number.EPSILON) * 1000) / 1000\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1460,
        "y": 400,
        "wires": [
            [
                "194804c392c89172",
                "236ea1364a916407"
            ]
        ]
    },
    {
        "id": "236ea1364a916407",
        "type": "delay",
        "z": "85dc5731.881ef8",
        "name": "",
        "pauseType": "timed",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "5",
        "rateUnits": "minute",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": true,
        "allowrate": false,
        "outputs": 1,
        "x": 1760,
        "y": 440,
        "wires": [
            [
                "a5e739635d2d4d37"
            ]
        ]
    },
    {
        "id": "a5e739635d2d4d37",
        "type": "ui_chart",
        "z": "85dc5731.881ef8",
        "name": "",
        "group": "e331a34b.02e348",
        "order": 2,
        "width": 6,
        "height": 4,
        "label": "Fuel Flow Rate Trend",
        "chartType": "line",
        "legend": "false",
        "xformat": "auto",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "0",
        "ymax": "2",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "604800",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 2011.375,
        "y": 443.4285583496094,
        "wires": [
            []
        ]
    },
    {
        "id": "194804c392c89172",
        "type": "ui_gauge",
        "z": "85dc5731.881ef8",
        "name": "",
        "group": "e331a34b.02e348",
        "order": 1,
        "width": 0,
        "height": 0,
        "gtype": "gage",
        "title": "Fuel Flow Rate - Stoker Sensor",
        "label": "m3/hr",
        "format": "{{value}}",
        "min": 0,
        "max": "2",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "diff": false,
        "className": "",
        "x": 1690,
        "y": 500,
        "wires": []
    },
    {
        "id": "4845ee5fdce680bb",
        "type": "debug",
        "z": "85dc5731.881ef8",
        "name": "buffer parser output",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1310,
        "y": 460,
        "wires": []
    },
    {
        "id": "a7cca763971d2b3d",
        "type": "debug",
        "z": "85dc5731.881ef8",
        "name": "debug 12",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1200,
        "y": 580,
        "wires": []
    },
    {
        "id": "d8b07ddb.c44d4",
        "type": "modbus-client",
        "name": "Boiler_PLC",
        "clienttype": "tcp",
        "bufferCommands": true,
        "stateLogEnabled": false,
        "queueLogEnabled": false,
        "failureLogEnabled": false,
        "tcpHost": "192.168.127.2",
        "tcpPort": "502",
        "tcpType": "DEFAULT",
        "serialPort": "/dev/ttyUSB",
        "serialType": "RTU-BUFFERD",
        "serialBaudrate": "9600",
        "serialDatabits": "8",
        "serialStopbits": "1",
        "serialParity": "none",
        "serialConnectionDelay": "100",
        "serialAsciiResponseStartDelimiter": "",
        "unit_id": "1",
        "commandDelay": "1",
        "clientTimeout": "1000",
        "reconnectOnTimeout": true,
        "reconnectTimeout": "2000",
        "parallelUnitIdsAllowed": true
    },
    {
        "id": "e331a34b.02e348",
        "type": "ui_group",
        "name": "Silo Status",
        "tab": "64088923.99b638",
        "order": 6,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "64088923.99b638",
        "type": "ui_tab",
        "name": "Boiler Status",
        "icon": "fa-bar-chart",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]

```

---

<div class="post-metadata">

**Author:** ![Darren](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/darren/32/92202_2.png) [@Darren](https://discourse.nodered.org/u/Darren)\
**Post date:** [18 September 2023 10:20 UTC](https://discourse.nodered.org/t/modbus-uint16-to-decimal/80498/35 "2023-09-18T10:20:35Z")

</div>

Thank you for your help, Steve!

---

<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:** [2 October 2023 10:21 UTC](https://discourse.nodered.org/t/modbus-uint16-to-decimal/80498/36 "2023-10-02T10:21:06Z")

</div>

Closed on 2 October 2023 10:21 UTC

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

[Previous page](https://discourse.nodered.org/t/modbus-uint16-to-decimal/80498.md?page=1)
