node-red-contrib-bytes-modpackqt 1.0.4
Universal byte / register decoder + encoder palette for Node-RED. Decode and encode int16, uint16, int32, uint32, float32, float64, strings, and bitmasks from any Buffer or numeric array — Modbus registers, MQTT payloads, raw TCP/UDP, BLE, LoRaWAN, file p
node-red-contrib-bytes-modpackqt
Universal byte / register decoder + encoder palette for Node-RED. By ModPackQT.
Decode and encode int16, uint16, int32, uint32, float32, float64, strings, and bitmasks from any Buffer or numeric array — Modbus registers, MQTT payloads, raw TCP/UDP, BLE, LoRaWAN, file parsing.
One node per type. Drop, wire, done.
Why this exists
Most binary-protocol packages bake decoding into the protocol itself (one giant node with a giant dropdown) or leave you writing a Function node every time. This palette gives you specialized blocks you can drop next to any source — Modbus, MQTT, TCP, BLE, file — and chain together cleanly.
[modbus master read FC3 qty=2] → [decode-float32 ABCD] → [debug]
[mqtt in: bytes] → [decode-int32 LE] → [if > 100] → [alert]
[ui slider] → [encode-float32 ABCD] → [modbus master write FC16]
Pairs perfectly with node-red-contrib-modbus-modpackqt — the Modbus palette outputs raw registers, this palette decodes them. Install both for the full experience.
Install
Palette manager: Menu → Manage palette → Install → search bytes-modpackqt.
npm:
cd ~/.node-red
npm install node-red-contrib-bytes-modpackqt
Nodes
Decoders (8)
| Node | Output | Width |
|---|---|---|
decode-int16 |
signed integer | 1 register / 2 bytes |
decode-uint16 |
unsigned integer | 1 register / 2 bytes |
decode-int32 |
signed integer | 2 registers / 4 bytes |
decode-uint32 |
unsigned integer | 2 registers / 4 bytes |
decode-float32 |
IEEE float | 2 registers / 4 bytes |
decode-float64 |
IEEE double | 4 registers / 8 bytes |
decode-string |
string (UTF-8 / ASCII / Latin-1) | variable |
decode-bitmask |
array of booleans | 1 register → 16 bits |
Encoders (6)
| Node | Input | Output |
|---|---|---|
encode-int16 |
number(s) | register array |
encode-uint16 |
number(s) | register array |
encode-int32 |
number(s) | 2-register groups |
encode-uint32 |
number(s) | 2-register groups |
encode-float32 |
number(s) | 2-register groups |
encode-float64 |
number(s) | 4-register groups |
Utility
| Node | Purpose |
|---|---|
endian-swap |
Re-order bytes / words in a register array |
Endianness, made simple
Every multi-byte node has an Endian dropdown:
| Option | Order | When to use |
|---|---|---|
| BE (default) | ABCD | Most modern PLCs, default Modbus |
| LE | DCBA | Little-endian devices, full reverse |
| BE_SWAP | BADC | Byte-swap within each word |
| LE_SWAP | CDAB | Word-swap (very common on Siemens / older PLCs) |
If your decoded value looks like garbage, try the other word order.
Input formats accepted
Decoder nodes accept any of:
msg.payload= Buffer → used as-ismsg.payload= array of 16-bit integers → treated as Modbus registers (default)msg.payload= array of bytes (0–255) → set Source to Byte array
Output is a single value (one input element) or an array (multiple).
Cookbook
Combined with the Modbus palette
Read a temperature float from a PLC — the most common Modbus pattern:
[inject every 5s] → [modbus master read FC3 addr=100 qty=2] → [decode-float32 BE] → [debug]
[16828, 0]→23.5- If value looks wrong, switch to
LE_SWAP(Siemens / older PLCs use CDAB)
Send a setpoint back — encode + write:
[inject 23.5] → [encode-float32 BE] → [modbus master write FC16 addr=200]
Decode a 32-bit energy meter (kWh):
[master read FC3 addr=300 qty=2] → [decode-uint32 LE_SWAP] → [debug]
// payload = 1234567 (kWh)
Parse a 16-bit status register into 16 booleans:
[master read FC3 addr=50 qty=1] → [decode-bitmask] → [function: payload[3] ? "fault" : "ok"]
Read a device serial number / nameplate string:
[master read FC3 addr=10 qty=8] → [decode-string BE encoding=utf8 trim=true] → [debug]
// payload = "SN-2025-A0042"
Mirror MQTT setpoints to PLC:
[mqtt in topic=plant/setpoint] → [encode-float32 BE] → [modbus master write FC16 addr=200]
Bridge PLC values to MQTT:
[poll every 1s] → [master read FC3 addr=100 qty=2] → [decode-float32 BE] → [mqtt out topic=plant/temp]
With other protocols (no Modbus needed)
Decode an MQTT byte payload (e.g. from a Sparkplug device):
[mqtt in] → [decode-int32 LE source=bytes] → [debug]
Decode a TCP/UDP frame from custom hardware:
[tcp in] → [decode-float64 BE source=bytes] → [debug]
Decode a BLE characteristic (Buffer payload):
[ble in] → [decode-uint16 LE source=bytes] → [debug]
Fix word order on incoming data, then decode:
[some source] → [endian-swap order=LE_SWAP width=4] → [decode-float32 BE] → [debug]
Examples
This package ships with two example flows under examples/:
decoder-recipes.json— six standalone patterns showing every decoder/encoder with mock inject sources (no PLC needed). Great for learning what each node does.combined-with-modbus.json— full end-to-end demo combining this palette withnode-red-contrib-modbus-modpackqt: read float from PLC → decode → debug; encode → write back; status bitmask; serial-number string.
Node-RED → Menu → Import → Examples → node-red-contrib-bytes-modpackqt.
For the combined example, also install node-red-contrib-modbus-modpackqt.
Pricing
Completely free, MIT licensed. No daily limits, no API key, no branding in node status. We make money on the Modbus palette's paid tier — this one is a gift to the community.
Pairs perfectly with
node-red-contrib-modbus-modpackqt— embedded Modbus master + slave server (the natural pairing — most users install both)- Standard
mqtt in/tcp in/serial in/udp innodes - Anything that emits a Buffer or numeric array
Troubleshooting
| Issue | Solution |
|---|---|
| Decoded value looks like garbage | Try another endian order — BE ↔ LE_SWAP covers 99% of mismatches |
decode-string returns scrambled text |
Some PLCs swap character pairs — switch Endian to LE |
| Encoder output is the wrong length | Multi-byte types output groups: int32 → 2 regs, float64 → 4 regs. Check your write FC accepts that quantity. |
| Bitmask returns more bits than expected | Set the Bits field to truncate (e.g. 8 for first byte only) |
Reporting bugs & getting updates
- Bugs / feature requests: use our contact page.
- Security issues: report privately via the security page.
- Updates are never automatic. Node-RED's palette manager will show
"update available" when we publish a new version. Pin a major version
(
^1.0.0) in production. - Changelog: the
CHANGELOG.mdfile is shipped inside this package. Decoders and encoders shipped today will keep producing the same output for the same input forever — that's a stability promise.
Links
License & disclaimer
MIT — © ModPackQT. Provided "as is" without warranty of any kind. You are responsible for validating this software in your environment before any production use.