# Modbus - Flex Write node - Parameters

**URL:** https://discourse.nodered.org/t/modbus-flex-write-node-parameters/99410
**Category:** General
**Created:** [16 October 2025 05:29 UTC](https://discourse.nodered.org/t/modbus-flex-write-node-parameters/99410 "2025-10-16T05:29:01Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)
#### Post date: [16 October 2025 05:29 UTC](https://discourse.nodered.org/t/modbus-flex-write-node-parameters/99410/1 "2025-10-16T05:29:01Z")

</div>

Hey Guys (hopefully @Steve-Mcl is listening !)

I am using the Modbus nodes extensively and not having any troubles - except i now want to pass two parameters through the Flex-write node and can not figure out the setup - here is my current code snippet from my function node

```auto
var values = [0x001,5000];
msg.payload = { 'value': values, 'fc': 16, 'unitid': 247, 'address': 0xb997, 'quantity': 2 }

```

and that works fine

I want to try and combine that with a 2nd write - as such

```auto
var values = [1,10];
msg.payload = { 'value': values, 'fc': 16, 'unitid': 247, 'address': 0xb995, 'quantity': 2 }

```

Is it possible to set two different registers by stacking the values in a variable ? If so what should the syntax look like - i have been playing with many options today but feel like i am going around in circles.

Both writes work - and if i issue them as two sequential commands i.e. Function 1 \> Modbus-write \> function 2 \> Modbus write it works fine - just hoping to tidy it up a bit more

regards

Craig

---

<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 October 2025 06:16 UTC](https://discourse.nodered.org/t/modbus-flex-write-node-parameters/99410/2 "2025-10-16T06:16:13Z")

</div>

Hi Craig, unfortunately the modbus protocoldoes not support non-sequential reads or writes. Whether the node actually supports multiple write operations internally (doing sequential writes itself), I can't remember. But it is simple enough to simulate using link-call.

Btw, if you are are working with a PLC, the better solution is to move the addresses adjacent to one another and send a write with contiguous data - that will result in a single network packet & consistent data.

---

<div class="post-metadata">

### Author: ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)
#### Post date: [16 October 2025 16:07 UTC](https://discourse.nodered.org/t/modbus-flex-write-node-parameters/99410/3 "2025-10-16T16:07:21Z")

</div>

Hi Steve

Thanks (as always !) for the speedy response. !

Yeah i am working with a GoodWe Solar Inverter rather than PLC gear so pretty much stuck with what i have been given.

OK just have to tidy up my spaghetti code now from playing and learning on this new unit and live with having to do a couple of writes.

regards

Craig

---

<div class="post-metadata">

### Author: ![ThingsTinkerer](https://avatars.discourse-cdn.com/v4/letter/t/91b2a8/32.png) [@ThingsTinkerer](https://discourse.nodered.org/u/ThingsTinkerer)
#### Post date: [17 October 2025 11:29 UTC](https://discourse.nodered.org/t/modbus-flex-write-node-parameters/99410/4 "2025-10-17T11:29:04Z")

</div>

We made a subflow to handle one or more requests (or ranges of requests), send requests individually then join them back into a single output message. It was worth it as it allows much more flexibility without having to manage multiple messages in the flow (outside the subflow). I think the built-in way to send requests is extremely granular and way too detailed.

Here you can see how it may look when generalized, sending 1 request with 2 ranges (adjusting address number off-by-one compared to device documentation):

```auto
msg.payload = {
  fc: 4,
  startAddressModifier: -1,
  addresses: [
    {
      power_production: { address: 3005, type: "uint32be", scale: 0.001, },
      dc_voltage_1: { address: 3022, type: "int16be", scale: 0.1, },
      dc_current_1: { address: 3023, type: "int16be", scale: 0.1, },
      dc_voltage_2: { address: 3024, type: "int16be", scale: 0.1, },
      dc_current_2: { address: 3025, type: "int16be", scale: 0.1, },
    },
    {
      fault_code_01: { address: 3096, type: "int16be", },
      fault_code_02: { address: 3097, type: "int16be", },
    },
  ]
};

```

We did the same thing with modbus write, so can send multiple requests in a single msg like this:

```auto
msg.payload = {
  topic1: {
    address: 123,
    value: 20
  },
  topic2: {
    address: 456,
    value: 30
  },
};

```

Here with default fc 6 and quantity 1 (otherwise it can be specified per request).

---

<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: [15 January 2026 11:29 UTC](https://discourse.nodered.org/t/modbus-flex-write-node-parameters/99410/5 "2026-01-15T11:29:50Z")

</div>

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