node-red-contrib-modbus-modpackqt 1.1.7

Node-RED nodes for ModPackQT — read/write Modbus TCP registers (master & slave) via the ModPackQT Gateway app. Supports FC1/FC2/FC3/FC4 reads and FC5/FC6/FC15/FC16 writes.

npm install node-red-contrib-modbus-modpackqt

node-red-contrib-modbus-modpackqt

Node-RED Modbus nodes powered by ModPackQT — drag-and-drop nodes to read and write Modbus TCP registers (master & slave) from your Node-RED flows. No hand-written HTTP calls. No protocol handling. Just connect and go.

npm version Node-RED License: MIT


What is ModPackQT?

ModPackQT is an industrial Modbus Master/Slave platform for engineers and technicians. It provides:

  • Modbus TCP and RTU communication via a local gateway app
  • Built-in slave simulator — simulate a PLC register map without hardware
  • Real-time data visualization, profile management, and AI-assisted setup
  • A REST API that this Node-RED palette talks to

👉 Download ModPackQT · Modbus Tutorial · Resources Hub

Requires the ModPackQT Gateway app to be running locally. The gateway is what the nodes talk to — not the cloud server directly.


Installation

Option 1 — Node-RED Palette Manager (recommended)

  1. Open Node-RED → Menu (☰) → Manage palette → Install
  2. Search for modbus-modpackqt
  3. Click Install
  4. Restart Node-RED — the ModPackQT palette group appears in the sidebar

Option 2 — npm CLI

cd ~/.node-red
npm install node-red-contrib-modbus-modpackqt
# Restart Node-RED after installation

Prerequisites

  1. Sign up at modpackqt.com A free account works for all master nodes. Slave nodes require a paid plan.

  2. Download and start the ModPackQT Gateway app Download it from modpackqt.com/download and run it. By default it listens on port 8502 (localhost:8502).

  3. Create an API key In the ModPackQT web app go to Settings → API Keys → New Key. Paste it into the modpackqt-config node.

  4. For slave nodes — create and start at least one slave in the ModPackQT app first (Slave Simulator → New Slave). Note the Slave ID shown — you'll need it in Node-RED.

Plan limits

Feature Free Paid
Master Read (modpackqt-master-read)
Master Write (modpackqt-master-write)
Slave Write (modpackqt-slave-write)
Slave Read (modpackqt-slave-read)

View plans & upgrade →


Available Nodes

Node Category Purpose
modpackqt-config Config Shared gateway connection (host, port, API key)
modpackqt-master-read Modbus Master Read Modbus TCP registers — FC1/FC2/FC3/FC4
modpackqt-master-write Modbus Master Write Modbus TCP registers — FC5/FC6/FC15/FC16
modpackqt-slave-read Modbus Slave (paid) Read registers from a ModPackQT slave
modpackqt-slave-write Modbus Slave (paid) Push values into a ModPackQT slave (build a live Modbus device from Node-RED)

Node-RED Modbus Master — Read Registers (FC1/FC2/FC3/FC4)

The modpackqt-master-read node reads registers from any Modbus TCP slave device by routing the request through the ModPackQT Gateway app.

Supported function codes:

  • FC1 — Read Coils
  • FC2 — Read Discrete Inputs
  • FC3 — Read Holding Registers
  • FC4 — Read Input Registers

Config options:

Property Description
Gateway Config node pointing at your running ModPackQT Gateway app
Target Host IP/hostname of the Modbus TCP slave to read from
Target Port Port of the Modbus TCP slave (default: 502)
Unit ID Modbus unit ID of the slave (1–247)
Function Code FC1 / FC2 / FC3 / FC4
Start Address First register address (0-based)
Quantity Number of registers/coils to read (1–125)
Poll Interval Auto-poll every N ms (0 = trigger on input msg only)

Output:

{
  "payload": { "success": true, "values": [100, 200, 300] },
  "topic": "modbus/read/192.168.1.10:502"
}

Node-RED Modbus Master — Write Registers (FC5/FC6/FC15/FC16)

The modpackqt-master-write node writes registers to any Modbus TCP slave device.

Supported function codes:

  • FC5 — Write Single Coil
  • FC6 — Write Single Holding Register
  • FC15 — Write Multiple Coils
  • FC16 — Write Multiple Holding Registers

Input: msg.payload — a number (FC5/FC6) or array of numbers (FC15/FC16)

Output: Original msg with msg.success = true


Building a Modbus Slave from Node-RED (Paid plan)

Use modpackqt-slave-write to make Node-RED the data source for a live Modbus slave device. Any external Modbus master (PLC, SCADA, HMI) that connects to the ModPackQT slave port will read whatever values you last pushed from Node-RED.

Typical flow:

[MQTT / Sensor / Timer] → [Function: scale to integer] → [modpackqt-slave-write addr=0] → [External Modbus master reads]

Use cases:

  • Publish MQTT sensor data as Modbus TCP registers
  • Simulate a PLC register map for HMI/SCADA testing
  • Bridge OPC-UA, REST, or database data to Modbus

Slave write input — all of these work:

msg.payload = 234;               // single integer
msg.payload = [234, 1013, 65];   // array — writes 3 registers starting at address 0
msg.payload = "[234, 1013, 65]"; // JSON string also works (inject string type)

Override at runtime:

msg.slaveId      = "42";    // select a different slave per message
msg.address      = 10;      // start at register 10 instead of the configured address
msg.registerType = "coil";  // override register type

Slave read output:

{
  "payload": {
    "values": [234, 1013, 65],
    "registerType": "holding",
    "address": 0,
    "quantity": 3,
    "slaveId": "42"
  },
  "topic": "slave/42/holding/0"
}

Example Flows

Poll Holding Registers Every 5 Seconds (Modbus Master)

[Inject (repeat 5s)] → [modpackqt-master-read FC3 target=192.168.1.10:502 unitId=1 addr=0 qty=10] → [Debug]

Write a Setpoint Register from a Button

[Inject (payload=1234)] → [modpackqt-master-write FC6 target=192.168.1.10:502 unitId=1 addr=100] → [Debug]

Build a Slave — Publish Sensor Data as Modbus (Paid plan)

[MQTT in] → [Function: msg.payload = parseInt(msg.payload * 10)] → [modpackqt-slave-write Holding addr=0] → [Debug]

Any Modbus master on the network now reads live sensor values from the slave.

Import the Demo Flow

  1. Open Node-RED → Menu → Import
  2. Choose examples/basic-flow.json from the package directory
  3. Update the config node with your gateway host/port
  4. Click Deploy

Configuration Node

Add one modpackqt-config node per gateway instance. All other nodes reference it.

Property Default Description
Host localhost Hostname or IP of the machine running the ModPackQT Gateway app
Port 8502 Port that the ModPackQT Gateway app listens on
API Key (empty) Optional — sent as x-api-key header if set

API Endpoints Used

Node Gateway Endpoint
modpackqt-master-read POST /api/modbus/tcp/read
modpackqt-master-write POST /api/modbus/tcp/write
modpackqt-slave-read GET /api/slaves/:id/registers
modpackqt-slave-write PATCH /api/slaves/:id/registers

Troubleshooting

Issue Solution
connect ECONNREFUSED localhost:8502 The ModPackQT Gateway app is not running. Start it first.
401 Unauthorized Missing or invalid API key — check modpackqt-config.
403 Forbidden on slave nodes Your plan does not include the Slave Simulator. Upgrade your plan →
slave not found — check Slave ID The Slave ID is wrong or that slave was deleted. Check in ModPackQT → Slave Simulator.
gateway not running on slave nodes The Gateway app is stopped. Open ModPackQT and click Start Gateway.
Cannot find module 'axios' Run npm install in ~/.node-red.
Nodes not appearing after install Restart Node-RED completely after npm install.
Node-RED version error Requires Node-RED ≥ 2.0.0 and Node.js ≥ 14.

Links


License

MIT — © ModPackQT

Node Info

Version: 1.1.7
Updated 4 days ago
License: MIT
Rating: 5.0 1

Categories

Actions

Rate:

Downloads

764 in the last week

Nodes

  • modpackqt-config
  • modpackqt-master-read
  • modpackqt-master-write
  • modpackqt-slave-read
  • modpackqt-slave-write

Keywords

  • node-red
  • modbus
  • modpackqt
  • modbus-tcp
  • modbus-rtu
  • modbus-master
  • modbus-slave
  • industrial
  • automation
  • holding-register
  • coil
  • iiot
  • plc

Maintainers