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.
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.
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)
- Open Node-RED → Menu (☰) → Manage palette → Install
- Search for
modbus-modpackqt - Click Install
- 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
Sign up at modpackqt.com A free account works for all master nodes. Slave nodes require a paid plan.
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).Create an API key In the ModPackQT web app go to Settings → API Keys → New Key. Paste it into the
modpackqt-confignode.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)✗ ✓
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
- Open Node-RED → Menu → Import
- Choose
examples/basic-flow.jsonfrom the package directory - Update the config node with your gateway host/port
- 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
- ModPackQT Homepage
- Download ModPackQT Gateway
- Free Modbus Tutorial
- Modbus Resources Hub
- Node-RED Docs
- Contact / Report an Issue
License
MIT — © ModPackQT