# Insert a float value in modbus contrib flex-servers buffer problems

**URL:** https://discourse.nodered.org/t/insert-a-float-value-in-modbus-contrib-flex-servers-buffer-problems/97158
**Category:** Industrial
**Tags:** modbus
**Created:** [20 May 2025 09:01 UTC](https://discourse.nodered.org/t/insert-a-float-value-in-modbus-contrib-flex-servers-buffer-problems/97158 "2025-05-20T09:01:14Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![stgj](https://avatars.discourse-cdn.com/v4/letter/s/e495f1/32.png) [@stgj](https://discourse.nodered.org/u/stgj)
#### Post date: [20 May 2025 09:01 UTC](https://discourse.nodered.org/t/insert-a-float-value-in-modbus-contrib-flex-servers-buffer-problems/97158/1 "2025-05-20T09:01:14Z")

</div>

Hi.  
I have some issues I don't understand with inserting float data in to the modbus flex-servers buffer and read that data with a modbus flex-getter when that data is in little endian.

First an example that I'm able to understand/work. Big endian.  
Function node preparing the insert to flex-server:

```auto
const airTemp = 5.0
const airTempBuffer = Buffer.alloc(4)
airTempBuffer.writeFloatBE(airTemp, 0)

msg.payload = {
    'value': airTempBuffer,
    'register': 'holding',
    'address': 5000,
    'disableMsgOutput': 1
}

return msg;

```

And in the body of the GetHolding in the flex-server you return this:

```auto
return node.registers.readUInt16BE(addr * node.bufferFactor)

```

Then the request preparation:

```auto
const request = {
    "fc": 3,
    "unitid": 1,
    "address": 5000,
    "quantity": 2
}
msg.payload = request
return msg;

```

The response payload:

```auto
{"data":[16544,0],"buffer":[64,160,0,0]}

```

With this I can interpret the data:

```auto
msg.payload.buffer.readFloatBE().toFixed(1)

```

This gives me "5.0"  
Nice!

But if I do this:

```auto
airTempBuffer.writeFloatLE(airTemp, 0)

```

The response payload is this:

```auto
{"data":[0,0],"buffer":[0,0,0,0]}

```

Why does little-endian give: {"data":[0,0],"buffer":[0,0,0,0]}  
Expected behavior in my mind would be something like this: {"data":[0,16544],"buffer":[0,0,64,160]}

Best regards  
Steffen

---

<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: [19 July 2025 09:02 UTC](https://discourse.nodered.org/t/insert-a-float-value-in-modbus-contrib-flex-servers-buffer-problems/97158/2 "2025-07-19T09:02:30Z")

</div>

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