node-red-contrib-modbus-modpackqt 1.1.6 → 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +61 -17
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -45,11 +45,28 @@ npm install node-red-contrib-modbus-modpackqt
45
45
 
46
46
  ## Prerequisites
47
47
 
48
- 1. **Download and start the ModPackQT Gateway app:**
48
+ 1. **Sign up at [modpackqt.com](https://modpackqt.com)**
49
+ A free account works for all master nodes. Slave nodes require a **paid plan**.
50
+
51
+ 2. **Download and start the ModPackQT Gateway app**
49
52
  Download it from [modpackqt.com/download](https://modpackqt.com/download) and run it.
50
53
  By default it listens on **port 8502** (`localhost:8502`).
51
54
 
52
- 2. For slave nodes, create and start at least one slave in the ModPackQT app first.
55
+ 3. **Create an API key**
56
+ In the ModPackQT web app go to **Settings → API Keys → New Key**. Paste it into the `modpackqt-config` node.
57
+
58
+ 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.
59
+
60
+ > **Plan limits**
61
+ >
62
+ > | Feature | Free | Paid |
63
+ > |---|---|---|
64
+ > | Master Read (`modpackqt-master-read`) | ✓ | ✓ |
65
+ > | Master Write (`modpackqt-master-write`) | ✓ | ✓ |
66
+ > | Slave Write (`modpackqt-slave-write`) | ✗ | ✓ |
67
+ > | Slave Read (`modpackqt-slave-read`) | ✗ | ✓ |
68
+ >
69
+ > [View plans & upgrade →](https://modpackqt.com/#pricing)
53
70
 
54
71
  ---
55
72
 
@@ -60,8 +77,8 @@ npm install node-red-contrib-modbus-modpackqt
60
77
  | `modpackqt-config` | Config | Shared gateway connection (host, port, API key) |
61
78
  | `modpackqt-master-read` | Modbus Master | Read Modbus TCP registers — FC1/FC2/FC3/FC4 |
62
79
  | `modpackqt-master-write` | Modbus Master | Write Modbus TCP registers — FC5/FC6/FC15/FC16 |
63
- | `modpackqt-slave-read` | Modbus Slave | Read registers from a ModPackQT simulated slave |
64
- | `modpackqt-slave-write` | Modbus Slave | Write registers into a ModPackQT simulated slave |
80
+ | `modpackqt-slave-read` | Modbus Slave *(paid)* | Read registers from a ModPackQT slave |
81
+ | `modpackqt-slave-write` | Modbus Slave *(paid)* | Push values into a ModPackQT slave (build a live Modbus device from Node-RED) |
65
82
 
66
83
  ---
67
84
 
@@ -114,21 +131,45 @@ The `modpackqt-master-write` node writes registers to **any Modbus TCP slave dev
114
131
 
115
132
  ---
116
133
 
117
- ## Node-RED Modbus Slave Read & Write Simulated Registers
134
+ ## Building a Modbus Slave from Node-RED *(Paid plan)*
118
135
 
119
- The `modpackqt-slave-read` and `modpackqt-slave-write` nodes interact with ModPackQT's **built-in slave simulator** a virtual PLC register map you control.
136
+ 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.
137
+
138
+ **Typical flow:**
139
+ ```
140
+ [MQTT / Sensor / Timer] → [Function: scale to integer] → [modpackqt-slave-write addr=0] → [External Modbus master reads]
141
+ ```
120
142
 
121
- **Register types:** Holding Registers, Coils, Input Registers, Discrete Inputs
143
+ **Use cases:**
144
+ - Publish MQTT sensor data as Modbus TCP registers
145
+ - Simulate a PLC register map for HMI/SCADA testing
146
+ - Bridge OPC-UA, REST, or database data to Modbus
147
+
148
+ **Slave write input — all of these work:**
149
+ ```js
150
+ msg.payload = 234; // single integer
151
+ msg.payload = [234, 1013, 65]; // array — writes 3 registers starting at address 0
152
+ msg.payload = "[234, 1013, 65]"; // JSON string also works (inject string type)
153
+ ```
154
+
155
+ **Override at runtime:**
156
+ ```js
157
+ msg.slaveId = "42"; // select a different slave per message
158
+ msg.address = 10; // start at register 10 instead of the configured address
159
+ msg.registerType = "coil"; // override register type
160
+ ```
122
161
 
123
162
  **Slave read output:**
124
163
  ```json
125
164
  {
126
165
  "payload": {
127
- "values": [0, 42, 100],
166
+ "values": [234, 1013, 65],
128
167
  "registerType": "holding",
129
- "address": 0
168
+ "address": 0,
169
+ "quantity": 3,
170
+ "slaveId": "42"
130
171
  },
131
- "topic": "slave/{slaveId}/holding/0"
172
+ "topic": "slave/42/holding/0"
132
173
  }
133
174
  ```
134
175
 
@@ -136,7 +177,7 @@ The `modpackqt-slave-read` and `modpackqt-slave-write` nodes interact with ModPa
136
177
 
137
178
  ## Example Flows
138
179
 
139
- ### Poll Holding Registers Every 5 Seconds (Node-RED Modbus Master)
180
+ ### Poll Holding Registers Every 5 Seconds (Modbus Master)
140
181
 
141
182
  ```
142
183
  [Inject (repeat 5s)] → [modpackqt-master-read FC3 target=192.168.1.10:502 unitId=1 addr=0 qty=10] → [Debug]
@@ -148,13 +189,14 @@ The `modpackqt-slave-read` and `modpackqt-slave-write` nodes interact with ModPa
148
189
  [Inject (payload=1234)] → [modpackqt-master-write FC6 target=192.168.1.10:502 unitId=1 addr=100] → [Debug]
149
190
  ```
150
191
 
151
- ### Inject Test Values into a Modbus Slave Simulator
192
+ ### Build a Slave Publish Sensor Data as Modbus (Paid plan)
152
193
 
153
194
  ```
154
- [Inject ([10,20,30])] → [modpackqt-slave-write Holding addr=0]
155
- [modpackqt-slave-read Holding addr=0 qty=3] → [Debug]
195
+ [MQTT in] → [Function: msg.payload = parseInt(msg.payload * 10)] → [modpackqt-slave-write Holding addr=0] → [Debug]
156
196
  ```
157
197
 
198
+ Any Modbus master on the network now reads live sensor values from the slave.
199
+
158
200
  ### Import the Demo Flow
159
201
 
160
202
  1. Open Node-RED → **Menu → Import**
@@ -191,9 +233,11 @@ Add one `modpackqt-config` node per gateway instance. All other nodes reference
191
233
 
192
234
  | Issue | Solution |
193
235
  |---|---|
194
- | `connect ECONNREFUSED localhost:8502` | Make sure the ModPackQT Gateway app is running. Check host/port in the config node. |
195
- | `404 Slave not found` | Check the Slave IDfind it in the ModPackQT app under your slave's settings. |
196
- | `Slave not running` (slave-write) | Start the slave in the ModPackQT app before writing. |
236
+ | `connect ECONNREFUSED localhost:8502` | The ModPackQT Gateway app is not running. Start it first. |
237
+ | `401 Unauthorized` | Missing or invalid API key check `modpackqt-config`. |
238
+ | `403 Forbidden` on slave nodes | Your plan does not include the Slave Simulator. [Upgrade your plan →](https://modpackqt.com/#pricing) |
239
+ | `slave not found — check Slave ID` | The Slave ID is wrong or that slave was deleted. Check in ModPackQT → Slave Simulator. |
240
+ | `gateway not running` on slave nodes | The Gateway app is stopped. Open ModPackQT and click Start Gateway. |
197
241
  | `Cannot find module 'axios'` | Run `npm install` in `~/.node-red`. |
198
242
  | Nodes not appearing after install | Restart Node-RED completely after `npm install`. |
199
243
  | Node-RED version error | Requires Node-RED ≥ 2.0.0 and Node.js ≥ 14. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-modbus-modpackqt",
3
- "version": "1.1.6",
3
+ "version": "1.1.8",
4
4
  "description": "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.",
5
5
  "keywords": [
6
6
  "node-red",
@@ -29,10 +29,10 @@
29
29
  "node-red": {
30
30
  "version": ">=2.0.0",
31
31
  "nodes": {
32
- "modpackqt-config": "nodes/modpackqt-config.js",
33
- "modpackqt-master-read": "nodes/modpackqt-master-read.js",
32
+ "modpackqt-config": "nodes/modpackqt-config.js",
33
+ "modpackqt-master-read": "nodes/modpackqt-master-read.js",
34
34
  "modpackqt-master-write": "nodes/modpackqt-master-write.js",
35
- "modpackqt-slave-read": "nodes/modpackqt-slave-read.js",
35
+ "modpackqt-slave-read": "nodes/modpackqt-slave-read.js",
36
36
  "modpackqt-slave-write": "nodes/modpackqt-slave-write.js"
37
37
  }
38
38
  },