Polling And Logging MODBUS RTU Device to CSV files
A complete guide to read data from MODBUS RTU serial devices and exporting parsed values directly into a CSV file with your value-column binding and log files rotation
1. Protocol Configuration: MODBUS RTU
Communication Type: Active Polling (Master/Slave over RS485/COM)
Because MODBUS transmits data in binary, the parser must extract specific Holding Registers (e.g., 40001) or Input Registers. If your sensor uses 32-bit floating-point numbers, configure the parser to read two adjacent 16-bit registers and apply the correct byte-swapping (endianness) to reconstruct the float.
Apply this base configuration for the serial connection:
{
"port": "COM3",
"baud_rate": 9600,
"data_bits": 8,
"stop_bits": 1,
"parity": "none",
"protocol": "modbus_rtu_serial",
"poll_interval_ms": 1000
}
MODBUS RTU plugin selection to query and parse data.

MODBUS RTU query queue: custom configuration to read different registers.
Ready to connect MODBUS RTU to CSV File?
2. Database Setup: CSV File
Use the built-in 'Local database' export module. No external drivers are necessary.
Use the following SQL script to create your target table. Do not log continuously into a single CSV file for years. Use the software's 'Log File Rotation' setting to automatically start a new file daily (e.g., `Log_YYYYMMDD.csv`). This prevents files from becoming too large to open in Excel.
No SQL required. You can define a custom header row in the plugin settings to match the exported variables.

Plugin selection to export parsed data to CSV or text files.

CSV export: file type selection and fine tuning.

CSV data formatting rules (date, numbers, etc.).

Column configuration in CSV files.
3. Protocol-Specific Troubleshooting
- Timeout or CRC errors: Unlike TCP, serial MODBUS RTU relies on strict timing. Verify that your RS485 A/B wires are not inverted, and that the baud rate and device ID in the software exactly matches the slave device.
- The device returns the "Illegal address" error code: Try to use the function #3 instead of the function #4 in your MODBUS request. Otherwise, verify that you are using the correct registe address. Try to specify an absolute offset (not logical address like 40001).
- I have several values that I want to export in one data row. Now, the logger writes one value per row: You need to enable the "Export all data at once" option in the MODBUS plugin settings.
4. Database-Specific Troubleshooting
- Excel opens the file but all data is squeezed into one column: This is a regional settings issue. In North America, the list separator is a comma (,), but in Europe, it is often a semicolon (;). Ensure the delimiter set in the Data Logger matches the regional settings of the PC opening the file.
- How to get my serial.print to be written into a CSV file: This is the simplest case. The logger does not need to process something in your case. Just enable logging to a file before parsing and change the log file extension to 'csv'.
- Can I write CSV data to a network share to use it from my computer?: Yes, you can specify the destination path as '\\server_name\folder\filename.csv'. If your incoming data is fast, it is better to create a new log file frequently, for example, every hour.