ModPackQTModPackQT
Node-RED ExamplesResourcesSign up
HomeResourcesNode-RED ExamplesRead Holding Registers (FC03)
ReadsNode-RED Modbus Example

Read Holding Registers (FC03)

Reading holding registers is the most common Modbus operation. This example polls 4 consecutive registers from a TCP slave every 5 seconds and logs the raw 16-bit values. It covers the basic wiring you'll reuse in almost every project.

What you need

  • Node-RED v3+ installed
  • node-red-contrib-modbus installed (npm install node-red-contrib-modbus)
  • A Modbus TCP slave device or simulator accessible on your network

Flow Overview


┌─────────────────┐    ┌──────────────────────────┐    ┌────────────────┐
│  Inject (5s)    │───▶│  Modbus Flex Getter       │───▶│  Debug (vals)  │
│  [trigger]      │    │  FC03 · addr:0 · qty:4    │    │                │
└─────────────────┘    │  Server: 192.168.1.100:502│    └────────────────┘
                       └──────────────────────────┘
                              Modbus TCP slave
                         (responds with 4 registers)

Node-RED Flow JSON

Node-RED Flow JSON
[
  {"id":"inj1","type":"inject","name":"Poll every 5s","repeat":"5","once":true,"wires":[["req1"]],"x":120,"y":100},
  {"id":"req1","type":"modbus-flex-getter","name":"FC03 Read","dataType":"HoldingRegister","adr":0,"quantity":4,"server":"srv1","wires":[["dbg1"],["dbg2"]],"x":320,"y":100},
  {"id":"dbg1","type":"debug","name":"Register values","active":true,"wires":[],"x":530,"y":80},
  {"id":"dbg2","type":"debug","name":"Modbus response","active":false,"wires":[],"x":530,"y":120},
  {"id":"srv1","type":"modbus-client","name":"My Slave","clienttype":"tcp","tcpHost":"192.168.1.100","tcpPort":502,"unit_id":1,"timeout":3000}
]

To import: open Node-RED → Hamburger menu → Import → paste this JSON → Deploy.

Expected Output

msg.payload = {
  data: [1234, 5678, 100, 0],   // raw UINT16 values
  buffer: <Buffer 04 d2 16 2e 00 64 00 00>
}

Common Gotchas

  • Register address 0 in Node-RED corresponds to datasheet address 40001 — you do NOT add 40000.
  • If the device does not respond, confirm the unit ID matches the slave's configured slave address.
  • The modbus-flex-getter output has two ports: port 1 = data, port 2 = full Modbus response object.
  • Default timeout is 1000 ms — increase it for slow serial-to-TCP gateways.
  • Multiple Modbus nodes sharing one modbus-client will queue requests, not send simultaneously.

Same in ModPackQT — in 30 seconds

In ModPackQT you do the same thing — enter the IP, port, start address, and count — and click Poll. No flow wiring required. Results appear in the register table instantly, with optional live graphing.

Was this example helpful?

More Reads examples

All Node-RED Modbus Examples (30)

ModPackQT · Node-RED Modbus Examples · Updated 2026