WritesNode-RED Modbus Example
Write a Single Coil ON/OFF (FC05)
Writing a coil controls a digital output — a relay, an LED, a solenoid. FC05 sets exactly one coil at a time. This example toggles a coil in response to a dashboard button press.
What you need
- Node-RED v3+
- node-red-contrib-modbus installed
- Modbus device with writable digital outputs (coils)
Flow Overview
┌──────────────┐
│ Inject ON │──┐
└──────────────┘ │ ┌────────────────────┐ ┌──────────────────────────┐
├──▶│ Function │──▶│ Modbus Flex Write FC05 │──▶ Debug
┌──────────────┐ │ │ fc:5, value:1 or 0│ │ addr:0 │
│ Inject OFF │──┘ └────────────────────┘ └──────────────────────────┘
└──────────────┘
Node-RED Flow JSON
To import: open Node-RED → Hamburger menu → Import → paste this JSON → Deploy.
Expected Output
// ON: value=1 → wire sends 0xFF00, OFF: value=0 → wire sends 0x0000 // Slave echoes the request back confirming the write
Common Gotchas
- In the node-red-contrib-modbus flex-write, set value to 1 (ON) or 0 (OFF) — the node translates to 0xFF00/0x0000 internally.
- Do NOT send 0xFF00 as the payload.value — the node expects 0 or 1, not the raw protocol values.
- The fc field in the payload must be 5 (number, not string '5').
- Coil address 0 = coil 00001 in 1-based notation.
- If you need to write multiple coils at once, use fc:15 with an array of 0/1 values.
Same in ModPackQT — in 30 seconds
ModPackQT has a coil toggle in every row of the register table. Click once to set ON, click again for OFF — no flow wiring, no function node needed.
Was this example helpful?
More Writes examples