ModPackQTModPackQT
Node-RED ExamplesResourcesSign up
HomeResourcesNode-RED ExamplesRead Input Registers (FC04)
ReadsNode-RED Modbus Example

Read Input Registers (FC04)

Input registers (3x range) are read-only 16-bit values — typically live sensor readings like temperature, pressure, or ADC counts. This example reads 8 input registers on a 2-second poll cycle.

What you need

  • Node-RED v3+
  • node-red-contrib-modbus installed
  • Modbus TCP slave with input registers

Flow Overview


┌──────────────┐   ┌──────────────────────────┐   ┌──────────────┐   ┌────────────┐
│ Inject (2s)  │──▶│ Modbus Flex Getter        │──▶│ Function     │──▶│ Debug      │
│              │   │ FC04 · addr:0 · qty:8     │   │ extract data │   │            │
└──────────────┘   └──────────────────────────┘   └──────────────┘   └────────────┘
                          Modbus TCP port 502
                    (slave's read-only process values)

Node-RED Flow JSON

Node-RED Flow JSON
[
  {"id":"inj2","type":"inject","name":"Poll 2s","repeat":"2","once":true,"wires":[["req2"]],"x":120,"y":200},
  {"id":"req2","type":"modbus-flex-getter","name":"FC04 Read","dataType":"InputRegister","adr":0,"quantity":8,"server":"srv1","wires":[["fn2"],[]],"x":320,"y":200},
  {"id":"fn2","type":"function","name":"Extract values","func":"msg.payload = msg.payload.data;
return msg;","wires":[["dbg3"]],"x":530,"y":200},
  {"id":"dbg3","type":"debug","name":"Input reg values","active":true,"wires":[],"x":730,"y":200},
  {"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 = [8432, 9100, 7234, 6001, 5500, 5498, 5502, 0]
// 8 UINT16 values from input registers 30001–30008

Common Gotchas

  • Input registers (FC04) and holding registers (FC03) have separate address spaces — address 0 in each refers to a different register.
  • Most energy meters expose real-time measurements (V, A, W) in the input register table.
  • You cannot write to input registers; use holding registers for setpoints.
  • The modbus-flex-getter dataType must be 'InputRegister' (capital I, capital R) — exact string match.
  • If your device only implements FC03, map input register addresses to holding registers in device settings.

Same in ModPackQT — in 30 seconds

ModPackQT lets you switch between FC03 and FC04 with a dropdown — no need to rewire a flow. The register table shows all values live with timestamps.

Was this example helpful?

More Reads examples

All Node-RED Modbus Examples (30)

ModPackQT · Node-RED Modbus Examples · Updated 2026