IntegrationNode-RED Modbus Example
Log Modbus Data to InfluxDB
Store Modbus register values as time-series data in InfluxDB for trending, analytics, and dashboards (Grafana, Chronograf). This example polls every minute, scales the values, and writes a measurement point.
What you need
- Node-RED v3+
- node-red-contrib-modbus installed
- node-red-contrib-influxdb installed (npm install node-red-contrib-influxdb)
- InfluxDB v1 or v2 instance
Flow Overview
Modbus Device Node-RED InfluxDB
│ │ │
│◀── FC03 ──────│ │
│── reg[0..3] ──▶│ │
│ │── scale & map to fields ──────▶ │
│ │ measurement: modbus_device │
│ │ tags: unit=1, line=line1 │
(Grafana reads ▶)
Node-RED Flow JSON
To import: open Node-RED → Hamburger menu → Import → paste this JSON → Deploy.
Expected Output
// InfluxDB point written every 60 seconds: // measurement=modbus_device // fields: temperature=24.5, voltage=230.12, current=1.234, power=285 // tags: unit=1, line=line1
Common Gotchas
- Scale raw register values in the function node before writing — InfluxDB stores what you send.
- For InfluxDB v2, use the influxdb-v2 output node and a token-based connection — different from v1.
- Tag values must be strings in InfluxDB; cast them if needed (String(unitId)).
- Keep the poll interval above the InfluxDB write precision — 1-second precision requires 1s polling.
- Handle Modbus errors: wire the second output of modbus-flex-getter to a catch node that avoids writing on failure.
Same in ModPackQT — in 30 seconds
ModPackQT has built-in CSV export for logged register values. For long-term storage you can also connect the ModPackQT MQTT output to an InfluxDB Telegraf bridge without writing any Node-RED flows.
Was this example helpful?
More Integration examples