= M-Bus Bridge

Serial bridge for meter communication using the M-Bus standard.

== Overview

M-Bus (Meter-Bus) is an international standard (EN 13757-2) for fieldbus communication with meter devices. The M-Bus Bridge enables OpenEMS to read data from M-Bus compatible meters such as water meters, gas meters, heat meters, and other utility meters via serial connection.

M-Bus is ideal for:

* Reading utility meters (water, gas, heat, electricity)
* Remote meter data collection
* Utility billing and energy management
* Building-level consumption monitoring
* Small industrial sites with metered devices

The bridge uses the jMbus library for protocol implementation and RxTx for serial port communication.

== Components

[[_bridge_mbus]]
=== Bridge M-Bus

*Name*: Bridge M-Bus

*Factory-PID*: `Bridge.Mbus`

*Purpose*: Master bridge for M-Bus serial communication with utility and facility meters.

*Use Cases*:

* Reading water meter consumption
* Monitoring gas meter usage
* Heat meter energy readings
* Electricity meter data collection (where available)
* Multi-meter installations
* Building energy accounting systems

.*Configuration*:

* `id` (String): Unique bridge identifier; default: `"mbus0"`
* `alias` (String): Human-readable name; default: same as id
* `enabled` (Boolean): Enable/disable this component; default: `true`
* `portName` (String): Serial port device name; default: `"/dev/ttyUSB0"`
  - Linux examples: `/dev/ttyUSB0`, `/dev/ttyS0`, `/dev/ttyACM0`
  - Windows examples: `COM1`, `COM3`
* `baudrate` (Integer): Serial communication speed in bps; default: `2400`
  - Standard M-Bus rates: 300, 2400, 9600, 19200

== Prerequisites

=== Hardware
* M-Bus compatible meter with serial interface
* USB-to-M-Bus adapter or RS-232/RS-485 interface
* Serial cable or M-Bus cable properly terminated

=== Software Dependencies
* jMbus library (included in bundle)
* RxTx native library for serial port communication

=== System Configuration

.Linux Installation (RxTx Native Library)
```bash
# Install RxTx native library
sudo apt-get install librxtx-java

# Typical location: /usr/lib/jni/librxtxSerial.so
# If not found, check: /usr/share/java/rxtx/

# If library not in standard location, copy to /usr/lib:
sudo cp /usr/share/java/rxtx/librxtxSerial.so /usr/lib/
```

.Serial Port Permissions (Linux)
```bash
# Add user to dialout group for serial port access
sudo usermod -a -G dialout $USER

# Log out and back in, or use:
newgrp dialout

# Verify permissions
ls -l /dev/ttyUSB0
```

.Windows Installation
* RxTx should be included with Java installation
* Verify serial port available in Device Manager
* Grant OpenEMS process permissions to serial port

https://github.com/OpenEMS/openems/tree/develop/io.openems.edge.bridge.mbus[Source Code icon:github[]]