M-Bus (Metering)
M-Bus (Meter-Bus) is a communication protocol standardized under EN 13757 and dedicated to utility metering. Heat meters, gas meters, electricity meters, and water meters are its primary markets.
The gateway's M-Bus driver supports M-Bus over TCP (wireless or wired meters converted to TCP through an M-Bus master gateway).
Registration Form Entries
| Field | What to enter | Example |
|---|---|---|
| IP address | M-Bus gateway IP | 192.168.0.150 |
| Port | M-Bus TCP port | 10001 (standard for Relay / Sentec / ETM class vendors) |
| Baud rate (baudrate) | gateway ↔ meter | 2400 (standard) / 9600 |
| Response timeout (request-timeout) | meter response wait (ms) | 5000 |
A single M-Bus line can carry up to 250 meters. The gateway includes a per-meter address (primary or secondary) in the tag-side notation so that multiple meters can be registered under a single "connection".
PLC Address Notation for Tags
Each M-Bus meter exposes various "records" (instantaneous value, totalized value, unit, and so on). The notation is split into the two parts <meter>:<record>.
Meter Selection
| Notation | Meaning |
|---|---|
addr:5 | Primary address 5 |
select:12345678:KAM:01:04 | Secondary selection — <id>:<mfg>:<ver>:<med> |
select:12345678 | Secondary id only (mfg/ver/med are wildcards FF) |
mfg is the 3-character manufacturer code (e.g. KAM = Kamstrup), ver is the firmware version, and med is the medium (1=Oil, 4=Heat, 7=Water, etc.).
Records (data block index)
A meter's response contains multiple data blocks (DIB/VIB), indexed sequentially as 0, 1, 2, ... The gateway exposes them using an index + subfield notation.
| Notation | Meaning |
|---|---|
1:0 | Field 0 of data block 1 (usually the "current value") |
1:unit | Unit of data block 1 (string) |
1:tariff | Tariff of data block 1 |
1:storage | Storage number of data block 1 |
Full notation example: addr:5:1:0 — the value of data block 1 on primary meter 5.
Or: select:12345678:KAM:01:04:3:0 — the value of data block 3 on a Kamstrup heat meter.
Matching Data Types
| M-Bus value | Data type | Type modifier |
|---|---|---|
| Totalized / measured value (real) | Float | REAL |
| Integer counter | Integer | DW (32-bit) or (blank) |
| Unit / manufacturer code | String | STR[8] |
| Tariff / storage number | Integer | (blank) |
M-Bus meters mix various encodings — BCD, 32-bit integer, 64-bit integer, IEEE real, and others. The driver decodes them automatically from the DIB / VIB headers and exposes them as "physical values", so in most cases you can simply receive them as Float : REAL.
Common Problems and Solutions
| Symptom / message | Possible cause | Solution |
|---|---|---|
| "Address not responding" | primary unused / conflicting | Use the gateway's "M-Bus scan" to identify which primary addresses actually respond |
| "Invalid secondary" | typo in one of the 4 secondary fields (id/mfg/ver/med) | Recheck the 8-digit serial on the meter label and the 3-character mfg code printed there |
| Value far too large / small (by 1000×) | scaling error | M-Bus normally scales automatically. If the value still looks wrong, correct it with a formula |
| Frequent "Timeout" | baud rate mismatch | Align the gateway ↔ meter baud rates (usually 2400) |
| Data block number unclear | the order differs per meter | Inspect the raw response with the gateway's "M-Bus telegram view" and map the index |
With 5–10 meters or fewer on a line, primary addressing is simpler. For 100+ meters, or systems where primary addresses change dynamically, secondary (serial-based) addressing is more reliable.
Frequently Used Examples
Standard registration for a single heat meter:
| Tag name | Address | Data type | Type modifier |
|---|---|---|---|
| Totalized heat (kWh) | addr:5:1:0 | Float | REAL |
| Totalized flow (m³) | addr:5:2:0 | Float | REAL |
| Instantaneous power (kW) | addr:5:3:0 | Float | REAL |
| Supply temperature (°C) | addr:5:4:0 | Float | REAL |
| Return temperature (°C) | addr:5:5:0 | Float | REAL |
| Meter serial number | addr:5:0:id | String | STR[8] |
More Detailed Examples / Automated Registration
See the M-Bus examples in Advanced — REST API.