Blog

Modbus Data Logger: A Practical Guide to Long-Term Logging on Site

2026-11-06 · 13 min read data loggerModbus TCPModbus RTUCSVtroubleshooting

Short answer

A Modbus data logger is a device or program that polls Modbus TCP or RTU registers at a fixed interval and saves each reading with a timestamp, usually to CSV files or a database. For long-term site logging, choose a few well-named tags, poll every 1 to 60 seconds, write one file per day, and make sure the logger restarts by itself after a power cut. A Raspberry Pi or an always-on PC running logging software works well when there is no SCADA historian.

The customer says the room gets too hot "some afternoons". The chiller trips "now and then". The energy bill doubled but nobody knows why. You can't stand in front of the controller for a week, and the BMS does not trend the points you need. What you need is a Modbus data logger: something that reads the same registers every few seconds, writes them down with a timestamp, and keeps going after you leave site.

This guide covers the logger options, choosing tags and poll intervals, file sizes, power cuts, safe remote access and opening the CSV in Excel. The method section shows each step with real screenshots in ModLens and the free ModLens Sim, so you can practise on your desk first.

What is a Modbus data logger?

A Modbus data logger is a Modbus client (master) that polls registers on a schedule and stores the values with a timestamp. On the wire it sends the same reads as any Modbus tool (function 03 for holding registers, 04 for input registers, 01/02 for coils and discrete inputs). The difference is everything around the reads:

  • it decodes each value correctly (data type, byte order, scale) so the file contains 21.8 °C, not 16814;
  • it writes to disk in a format you can analyse (CSV or a database);
  • it keeps running for days or weeks without anyone touching it;
  • it recovers from power cuts, cable faults and devices that stop answering.

A logger is only as good as its tag list: confirm each value against the device display before logging. Our guides on finding a Modbus register address and float byte order (ABCD, CDAB) cover that part.

When do you need long-term Modbus logging?

You need a logger when the problem does not happen while you are watching:

Situation What to log Typical interval
Intermittent fault (trip, alarm, comfort complaint) The process value, setpoint, command, status and alarm bits around the fault 1–5 s
Energy study or baseline kW, kWh counters, power factor, voltage per phase 15–60 s
Proving a problem to the client or another trade The value in dispute plus the conditions (outdoor temp, occupancy) 10–60 s
Commissioning sign-off / trend review Supply and return temperatures, valve and fan commands, pressures 10–30 s
Tuning a control loop Process value, setpoint and output of that loop only 1 s or faster

Modbus data logger options: which one fits?

There are four common ways to log Modbus data on site:

Option Good for Watch out for
SCADA / BMS historian Sites that already have one, permanent trends You may not have access, licences may limit trended points, slow to change
Laptop with logging software Short jobs (hours to a day or two), while you are on site Sleep mode, Windows updates, laptop leaves with you
Dedicated hardware data logger Permanent installs, harsh panels, cellular upload Fixed feature set, vendor-specific setup tools, check the vendor's site for supported data types and price
Raspberry Pi or small always-on PC with logging software Days to months on site, remote dashboard, low cost SD card wear, clock without network, needs a proper power supply

If the site has a historian and you can add points to it, use it. Often the points you need are not trended, or you have no access; then a separate logger is faster. For a step-by-step Pi build, see Build a Modbus Data Logger with a Raspberry Pi.

How to choose tags for a Modbus data logger

Log few, well-chosen tags, not every register. For a fault investigation, log for each piece of equipment:

  1. The process value that the complaint is about (room temperature, discharge pressure, kW).
  2. The setpoint it is controlled to, because a "high temperature" with a changed setpoint is a different story.
  3. The command or output (valve %, fan speed, compressor stage).
  4. Status and alarm bits (running, fault, filter alarm, occupancy).
  5. One or two context values (outdoor temperature, supply voltage).

For each tag, record unit ID, table, address, data type, byte order, scale and unit, and a name a colleague will understand: "AHU-1 Supply air temp" beats "HR0".

Group registers to keep polling fast

Each Modbus request has overhead, so reading 10 registers in one request is much faster than 10 requests of 1 register. The Modbus Application Protocol specification allows up to 125 registers per read (function 03 or 04). Many devices accept less, and some return exception 02 if the block includes an address that does not exist. A good logger groups nearby tags into one read and falls back to single reads when a block fails.

Choosing the poll interval

Poll as slowly as the question allows (see the table above). A 1-second interval loads slow RS-485 buses and adds little for temperatures that change over minutes. Energy counters integrate by themselves, so reading them every few minutes is enough. For short trips, log the device's own fault latch so an event between two reads is not missed.

Worked example: how fast can an RTU bus be polled?

On Modbus RTU, the bus speed sets a hard limit. The Modbus Serial Line specification uses 11 bits per character (start bit, 8 data bits, parity or a second stop bit, stop bit).

Reading 10 holding registers from one device:

  • Request: address, function, start address, quantity, CRC = 8 bytes.
  • Response: address, function, byte count, 20 data bytes, CRC = 25 bytes.
  • Total: 33 bytes × 11 bits = 363 bits.
  • At 9600 baud: 363 / 9600 = about 38 ms on the wire.
  • Add the silent gaps (3.5 characters ≈ 4 ms at 9600 baud, before each frame) and the device's own response time, often several to tens of milliseconds.

So one read takes roughly 50–100 ms at 9600 baud. Ten devices with two reads each is 20 reads, or 1–2 seconds per cycle. That bus cannot be logged every 1 second, and trying to will cause timeouts. At 19200 baud the wire time halves. Modbus TCP is much faster, but the device's processor and a gateway in between may still be the bottleneck.

How big do Modbus CSV log files get?

Smaller than most people expect. In the test for this article, ModLens logged 6 tags every second: the file grew to 1,962 bytes for 34 rows plus the header, about 54 bytes per row.

From that real figure:

Interval Rows per day Size per day (6 tags) 90 days
1 s 86,400 ≈ 4.7 MB ≈ 420 MB
10 s 8,640 ≈ 470 KB ≈ 42 MB
60 s 1,440 ≈ 78 KB ≈ 7 MB

Size grows with the number of tags, but even a few dozen tags fit easily on a 32 GB card. Two limits matter more:

  • Excel opens at most 1,048,576 rows per worksheet. One file per day at 1 s (86,400 rows) is fine; one big file for a month at 1 s is not.
  • SD cards wear out with constant writing. Use a "high endurance" card in a Pi and let the logger delete old files automatically.

Surviving power cuts and network loss

Power events are often part of the fault, so check these four points before you leave site:

  1. Automatic start. On a Pi or Linux box, run the logger as a service. On Windows, start it with Windows, ideally before login, and never let the PC sleep.
  2. Power-on after an outage. A Pi boots when power returns. Most PCs do not, unless the BIOS/UEFI setting "Restore on AC power loss" (also called "AC back" or "Power on after power failure") is set to Power On.
  3. Logging resumes on its own, without a click.
  4. Correct time. A Pi with network access syncs its clock; most Pi models have no battery-backed clock (the Pi 5 has one but needs a battery fitted), so on an isolated network add an RTC module.

When a device stops answering, a good logger keeps polling the others and writes an empty cell, not a repeated old value. Don't fill gaps during analysis: a gap is information.

Remote access to the logger, done safely

Modbus itself has no authentication: anyone who can reach port 502 can read and often write registers. The newer Modbus/TCP Security specification adds TLS on port 802, but most field devices do not support it.

  • Never forward port 502 or the logger's dashboard from the internet.
  • Use the customer's VPN or a remote-access gateway they approve.
  • Protect the dashboard with a strong password and give the logger a fixed IP.
  • Keep the logger read-only.

How to set up a Modbus data logger in ModLens, step by step

Here is the method in ModLens, polling the free ModLens Sim example (an AHU controller on unit ID 1, a power meter on unit ID 2). It works the same on Windows or a Raspberry Pi. You can follow along with the free 14-day trial; CSV logging is a Pro feature, included in the trial.

Step 1: Confirm each value and create a tag

First confirm each register against the device (Explorer or Find a value), then save it as a tag. In Live & tags, click + Add tag and fill in where the value is and how to decode it.

ModLens New tag form for Active power: device ModLens Sim example, unit ID 2, Input registers (3x), address 4, float32, byte order CDAB (word swap), scale 1, unit kW, alarm above 15

Here the meter's Active power is on unit ID 2, input register 4, float32 with CDAB (word swap) byte order, unit kW, with an alarm above 15 kW. Value shown = raw × scale + offset, so an int16 of 215 with scale 0.1 gives 21.5. If you are unsure about a float, the free Modbus register converter decodes two raw registers in every byte order.

For this example, six tags were created: Supply air temp (unit 1, holding 0, int16 × 0.1), Return air temp (holding 1, float32 ABCD), Duct static pressure (holding 3, float32 CDAB), Voltage (unit 2, input 0, float32 CDAB), Energy (input 10, uint32) and Active power.

Step 2: Start live monitoring and turn on Log to CSV

Set Every (s) to the poll interval, click ▶ Start live, then tick Log to CSV.

ModLens Live & tags running every 1 s with Log to CSV ticked: six tags with values 14.8 °C, 21.73 °C with a HIGH badge, 1.53 inWC, 230.6 V, 512000 kWh and 6.9 kW, plus a trend of Supply air temp

The status line reads "Live · every 1s · 28 cycles · logging to CSV". Each row shows the value with its unit, the location ("u2 · input 4") and the type ("float32 CDAB"). One second was used only so the screenshots fill quickly.

Step 3: Check the trend and alarms before you leave

Click a tag to see its trend for the last 15 minutes, and set alarm limits on the values that matter.

ModLens trend of Return air temp between 21.67 and 21.87 °C over 30 seconds, and the Recent alarms list showing Return air temp above 21.5: 21.81

In this test, the Return air temp alarm limit was set to 21.5 °C, just under the simulated value, so the alarm shows: "Return air temp above 21.5: 21.81" and a HIGH badge on the row. Before leaving site, check that every tag updates and no row shows "Error".

Step 4: Download the daily CSV files

The Logs page lists the CSV files, one per day, with size and last update. Click Download, or on a Pi copy them over the network.

ModLens Logs page listing My_project_2026-11-02.csv, 1.7 KB, with a Download link

The first lines of the real file from this test:

timestamp,Supply air temp [°C],Return air temp [°C],Duct static pressure [inWC],Voltage [V],Energy [kWh],Active power [kW]
2026-11-02T12:15:29,14.5,21.82,1.42,230.0,512000,6.9
2026-11-02T12:15:30,14.4,21.79,1.41,230.0,512000,6.9
2026-11-02T12:15:31,14.5,21.81,1.43,230.3,512000,6.9

If you add or rename a tag while logging, ModLens starts a new file for the rest of the day, so the columns never shift under an old header.

Step 5: Set how long to keep logs

In Settings → Logging, choose how many days of CSV files to keep. Older files are deleted automatically, so a Pi's SD card never fills up. The default is 90 days; 0 keeps everything.

ModLens Settings Logging card with Keep logs for (days) set to 90 and a Save button

Step 6: Make it run 24/7

On Windows, Run in the background (24/7) keeps ModLens running in the tray and can start it with Windows. Make this PC always on starts it before login, restarts it if it stops, and keeps the PC awake.

ModLens Settings showing Keep running in the tray, Start ModLens with Windows, the Make this PC always on button and the BIOS tip Restore on AC power loss set to Power On

On a Raspberry Pi, the installer sets ModLens up as a service that starts at boot and resumes logging (see the install and user guide). For a Pi left on site, the Pi Logger licence ($49 one-time) covers one device; details are on the pricing page.

Reading the Modbus CSV in Excel without surprises

Three common traps:

  • Columns all in one. In countries that use a comma as the decimal separator, double-clicking a comma-separated file can put everything in column A, or turn 21.82 into a date. Use Data → From Text/CSV, choose Comma as the delimiter and a locale that uses a dot for decimals (for example English (United States)).
  • Timestamps as text. ISO timestamps like 2026-11-02T12:15:29 contain a "T". If Excel shows them as text, replace the "T" with a space (Find & Replace) or use a formula such as =--SUBSTITUTE(A2,"T"," ") with a date-time format.
  • The logger cannot write while the file is open. On Windows, Excel locks the file it has open, so rows written at that moment can be lost. Copy the file first and open the copy.

Then chart the columns you need against the timestamp. For energy, last kWh minus first kWh gives consumption; a sudden drop means counter rollover or a reset.

Common mistakes with Modbus data loggers

  • Logging unverified registers. A wrong byte order logs nonsense like 2.9e30 for a week. Confirm each tag against the display first.
  • Polling too fast on RS-485. The bus cannot keep up, reads time out, and the log fills with gaps. Use the timing example above.
  • Laptop going to sleep. Power settings, lid close and Windows updates stop logging silently. Use an always-on PC or a Pi.
  • Two masters on one RS-485 bus. Modbus RTU allows only one master per bus. If a BMS already polls the bus, connect your logger to the BMS side or a gateway that supports multiple clients, not in parallel on the same pair.
  • Leaving no note. Tape a label on the logger with your name, phone number and the removal date, so nobody unplugs it.

FAQ

What is the best Modbus data logger?

It depends on the job. Use the site's SCADA or BMS historian if you can add points to it. Otherwise a Raspberry Pi or always-on PC with logging software is flexible and low-cost, and a hardware logger suits permanent installs. Choose one that decodes floats and byte orders correctly and resumes after power cuts.

Can I log Modbus data to CSV for free?

Yes, free and open-source scripts and tools can write CSV files, but you usually handle auto-start and power-cut recovery yourself. ModLens includes CSV logging in its free 14-day trial; after the trial, logging is part of Pro, while the free Lite mode keeps basic reads and writes.

How often should a Modbus data logger poll?

Poll as slowly as the question allows: 10 to 60 seconds for temperatures and energy, 1 to 5 seconds for pressures, flows and fast faults. On Modbus RTU, check that the bus can actually complete all reads within the interval; at 9600 baud a single read takes roughly 50 to 100 ms including device response time. Polling faster than the bus allows causes timeouts and gaps.

How much storage does Modbus logging need?

Very little. In our test, 6 tags logged every second took about 54 bytes per row, which is about 4.7 MB per day, or about 78 KB per day at a 60-second interval. Keep one file per day so each file stays under Excel's limit of 1,048,576 rows, and delete old files automatically on small devices.

Can a Raspberry Pi log Modbus RTU and Modbus TCP?

Yes. Modbus TCP works over Ethernet or Wi-Fi, and Modbus RTU through a USB to RS-485 adapter. Run the logging software as a service so it starts at boot and resumes after a power cut.

Can I add a data logger to a Modbus RTU bus that a BMS already polls?

Not directly: Modbus RTU allows only one master on a bus, and two masters talking at the same time corrupt each other's frames. Read the values from the BMS side instead, use a gateway that lets several TCP clients share the serial bus, or put the logger on a separate port of the device if it has one. With Modbus TCP, several clients can usually connect to the same device, within the device's connection limit.

Is it safe to access a Modbus logger remotely?

Only through a secure path. Never expose port 502 or the dashboard to the internet; use the customer's VPN, a strong dashboard password, and keep the logger read-only.

What happens to logging after a power cut?

That depends on the logger. A well-set-up logger starts automatically when power returns and resumes logging without anyone touching it; a Pi boots by itself, while a PC needs "Restore on AC power loss" set to Power On in the BIOS. Check the timestamps after the restart, because a device without a working clock can log with the wrong date.