Polling And Logging Water Meters to Postgre SQL
A complete guide to read data from RS232 water meters and exporting parsed values directly into a PostgreSQL database with your database structure.
1. Protocol Configuration: Flow & Water Meters
Communication Type: Active Polling (M-Bus / MODBUS)
Industrial water meters usually communicate via M-Bus (Meter-Bus) over RS232/RS485 using a level converter. Use the 'M-Bus Data Parser' plugin. The logger sends a REQ_UD2 (Request for Class 2 Data) frame to the specific meter address, and the parser will decode the responding telegram into volume, flow rate, and temperature variables.
Apply this base configuration for the serial connection:
{
"port": "COM2",
"baud_rate": 2400,
"data_bits": 8,
"stop_bits": 1,
"parity": "even",
"protocol": "mbus_en13757",
"poll_interval_ms": 60000
}
M-Bus plugin selection to read water meter data.

M-Bus plugin configuration.
Ready to connect Flow & Water Meters to PostgreSQL?
2. Database Setup: PostgreSQL
Install the PostgreSQL ODBC Driver (psqlODBC) on the server running Advanced Serial Data Logger. Create a System DSN or use a direct connection string in the SQL Database Professional plugin like 192.168.1.100:mydatabase.
Use the following SQL script to create your target table. Ensure your user role has INSERT privileges for the target schema. Use the NUMERIC data type to prevent floating-point precision loss from raw sensor data.
CREATE TABLE rs232_logs ( id SERIAL PRIMARY KEY, log_timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP, device_name VARCHAR(50), extracted_value NUMERIC(10, 2) );

PostgreSQL database connector selection.

PgSQL database connection settings.

SQL queue to insert data in your table.
3. Protocol-Specific Troubleshooting
- Receiving garbage hex data instead of M-Bus telegrams: M-Bus strictly requires Even parity. Check your COM port settings in the Data Logger and ensure it is set to 8 Data Bits, 1 Stop Bit, and Even Parity.
- The logger displays non-readable data (strange characters) instead of expected HEX codes: You need to change the "Data View" mode in logger's settings. Select "Display as #XX" for all byte ranges.
- What values can the logger read: M-Bus allows the logger to read all available values at once. The logger exports them as separate values (variables).
4. Database-Specific Troubleshooting
- FATAL: password authentication failed: Verify that your pg_hba.conf file allows connections from the Data Logger's IP address (if remote) and that the authentication method is set to md5 or scram-sha-256.
- I have two similar records with the same timestamp in my database for every record: Verify that you do not use two data export plugins at the same time. For example, ODBC Database and SQL Database Pro because they can export your data in parallel.
- I've installed ODBC drivers and created a DSN, but your software does not allow me to select it.: Our software requires 32-bit ODBC drivers. Therefore, you should install this version of drivers to create a DSN in the 32-bit ODBC Administrator. You can use the 'Setup' button in the 'ODBC Database' plugin to do it.