IMD SolutionComputing LibraryShop main store

How-to

Write a Modbus TCP value to a groov Data Store from Node-RED

Edge computing and IIoT Published 6 min read By IMD Solution engineering team

Short answer

A Modbus TCP value fails to land in a groov Data Store tag because the groov Write node reads the msg property you configure, and the Modbus-Read node delivers its values at a different path. Set a Debug node to complete msg object, read the real path, and enter it in the write node; for a whole table, build one message object per element and pass them through a Split node into a single groov Write node.

On this page
  1. Why the manual test writes and the live value does not
  2. Read the real property path with a Debug node
  3. Point the groov Write node at the Data Store
  4. Write a whole table through one groov Write node
  5. Worked example: four registers into a four-row table
  6. Verify the write end to end
  7. Questions asked

The groov Write node is not refusing Modbus data. It writes whatever value it finds in the msg property it is configured to read, and that configured property rarely matches the one the Modbus-Read node fills. A manual test that injects the value as msg.value passes because the Inject node builds exactly the property the write node expects; the live Modbus reading never arrives there, so nothing reaches the Data Store. The fix is two moves: set a Debug node to show the whole message, read the property path where the Modbus node actually leaves its values, and enter that path in the groov Write node. To fill an entire table, string, float or integer, build one message object per element in a Function node and let a Split node feed a single groov Write node one write per index.

Why the manual test writes and the live value does not #

The groov Write node takes its value from a named msg property, and that name is part of the node's configuration. When you inject a message that carries the value in msg.value and the write succeeds, you have proven the node, its connection to the groov View project and the tag itself; you have proven nothing about the Modbus side. The Modbus-Read node delivers its reading at its own path, normally the payload property, one element per register read. Because the write node listens on msg.value, the live message passes by unheard. Configure the source before the sink: read the Modbus path from a Debug node first, then type it into the write node. That Debug-before-configuring step is the same one that turns a raw Modbus TCP payload into InfluxDB fields in Node-RED without guessing a property name.

Read the real property path with a Debug node #

  1. Deploy the flow with the Modbus TCP node polling the device, for example a read of four holding registers on a device at 192.168.1.50, unit 1.
  2. Wire a Debug node to the Modbus node's output and open its edit panel.
  3. Set the Debug node's output to complete msg object. The default view shows only the payload; the whole message is what lists every property the node emits.
  4. Trigger one read and expand the result in the debug sidebar. Note the exact path that carries the register values: for a Modbus-Read node this is normally msg.payload, one array element per register.
  5. Open the groov Write node, enter that path in the field that names the property the node reads its value from, and redeploy.

Point the groov Write node at the Data Store #

The write node targets a tag the groov View project's Data Store already defines, so select that tag in the node's configuration. Configure the connection to the groov project as well; the node talks to the project over HTTPS, and if the connection fails with a certificate error rather than a write error, that fault has its own fix in why Node-RED on a PC rejects the groov Data Store certificate.

Test the path before trusting it: fire a manual Inject node that sets the property you found, and confirm the tag changes once. When the manual write lands, wire the Modbus node's output straight into the groov Write node.

Write a whole table through one groov Write node #

One groov Write node per tag index is the simple pattern, fine for two or three fixed positions; for a long table it becomes a wall of nodes. The pattern that scales is three nodes: a Function node turns the list into a payload array of message objects, a Split node separates them, and a single groov Write node performs every write. The same pattern serves string tables, float tables and integer tables.

The two field names each object needs, the value and the table index, are fixed by the groov Write node, not by this pattern. The write node's edit dialog shows what it reads, and the vendor's Node-RED for groov View documentation describes how the nodes write Data Store tags; the names in the example below are illustrative, so match them to the dialog before deploying:

// msg.payload arrives as an array of values, for example [362, 371, 380, 389]
// "value" and "index" are illustrative field names: use the ones the
// groov Write node's edit dialog shows for the object it writes
let rows = msg.payload.map(function (v, i) {
    // v is the element's value, i its position in the array
    return { value: v, index: i };
});
msg.payload = rows;
return msg;

Follow the Function node with a Split node in its default array mode, which emits one message per element, and route that into the single groov Write node. Keep the field names identical on both sides: a mismatch hands the write node an object it cannot read, and the table stays empty.

Write shape Flow Use it when
One value Modbus node into groov Write node, value path from the Debug step A scalar tag mirroring one register
A few fixed indices One groov Write node per index Two or three positions that rarely change
A whole table Function node into Split node into one groov Write node Any list long enough that per-index nodes become unmanageable

Worked example: four registers into a four-row table #

Say the Modbus-Read node polls four holding registers, the first at address 40001 (data address 0), on the device at 192.168.1.50, and the Debug node shows msg.payload = [362, 371, 380, 389]. Element i of that array carries the register at data address i, which is register 40001 + i in the usual five-digit convention, so element 2 is register 40003.

The Function node loops i from 0 to 3 and builds four objects; the Split node emits four messages; the groov Write node performs four writes. With the index field taken from the loop counter, table rows 0 through 3 receive 362, 371, 380 and 389 in order. To begin at row 1 instead, push the objects with index i + 1 and the same four values land in rows 1 through 4: the loop arithmetic sets the offset, not the write node. A ten-row table becomes ten messages and ten writes through the same three nodes.

Verify the write end to end #

  • Put a known test value in the first register from the PLC or the device's own tools, and confirm the Debug pane shows it at the configured path.
  • Confirm the tag, not just the flow: open the Data Store tag or a groov View page bound to it, and check the test value and its write time.
  • Check the tag's declared type against the values you send; if the table is declared as one type and the device produces another, correct the declaration or the values instead of letting the mismatch stand.
  • If a manual Inject writes but live Modbus values never do, the property path in the write node is the one setting that differs between the two messages. Correct it before restructuring the flow.

One boundary worth keeping: these Data Store values feed operator displays and logs, never a safety function. A safety decision belongs in the machine's certified safety system, not in a Node-RED flow.

Questions asked

Does the Data Store tag need to exist before the flow writes?

Yes. Data Store tags live in the groov View project configuration, so create the Data Store, add the tag or table there with its declared type, string, float or integer, and save the project before wiring the flow. The write node can only target a tag the project already defines; a write aimed at a tag that does not exist has nowhere to land.

Where does a Modbus-Read node put the register values?

Normally in the payload property, as an array with one element per register read, so the first register of a read is element 0. The shape can differ with the node version and the function code, because coils read differently from registers, so set a Debug node to complete msg object, trigger one read, and read the path from the actual message.

Can the table write start from data other than a Modbus read?

Yes. The Function node only needs an array to loop over, so a database query result, a parsed message or a computed batch feeds the same Split-and-write pattern; the Modbus read is one producer among many. Whatever fills the array, keep the object field names identical to the ones the groov Write node reads.

Keep reading

  • Troubleshooting

    Scaling Node-RED from 20 to 1000 Modbus tags into SQL Server

    Yes: 1,000 Modbus tags at a one-minute interval is 16.7 values per second and fits Node-RED writing to SQL Server, provided reads are grouped per device and each poll-plus-insert cycle finishes well inside the logging window. The budget below puts a grouped design at about 3.5 seconds per cycle and a per-tag design at 51 seconds, which ten device timeouts push past the deadline.

    Edge computing and IIoT

  • Comparison

    Historian-like data logging on a restricted edge network

    On a restricted plant network the approved destination decides the architecture: write directly from Node-RED to the database when that connection is approved, publish MQTT and land it in InfluxDB with Telegraf when only a broker is approved, and capture to local files when nothing outbound is allowed. Whatever the path, prove store-and-forward with an outage test sized from your tag count and write period.

    Edge computing and IIoT

  • How-to

    Log production data from a panel PC to SQL Server

    Run Node-RED on the panel PC, read the production values straight from the controller, and insert one row per event into SQL Server with the mssql-plus node. Keep the panel's CSV-plus-FTP file relay only as a fallback, block duplicates with a last-record check and a unique key, and expect about 86,400 rows, roughly 8.6 MB, per day at one record per second.

    Edge computing and IIoT

Manual lab data entry into a historian: choosing the write path