M-Bus (Meter-Bus) on Raspberry Pi Integration

I’d like to share how I managed integrate an M-Bus connected water meter into HA. M-Bus or Meter-Bus is a specification for a serial bus and communication protocol that is popular for smart meters. These meters usually have long-lasting batteries (10 years+) that will last even longer when the meter can draw power from the bus. In this way the meter has a persistent counter value, and one doesn’t miss any counts, even if the meter is not read for a while.

Unfortunately most M-Bus interfaces are quite expensive, but a cost-effective solution is available for the Raspberry Pi as a so-called Hat from packom.net. They also provide a RESTful server mbus-httpd) that runs on the Raspi, which in turn can be integrated into HA via the rest platform. The RESTful server returns XML formatted meter data (in my case counted water volume, timestamp, etc.), without requiring any instructions. Apparently the M-Bus interface provides the server with all of this information.

I am running HA OS on a different Raspi than the one that runs the RESTful server. The respective part of my configuration.yaml looks roughly as follows:

  # water meter
  - platform: rest
    resource: http://raspberrypi.home:8080/mbus/get/ttyAMA0/2400/0
    method: POST
    name: "water meter"
    value_template: "{{ value_json.MBusData.DataRecord[0].Value | int }}"
    unit_of_measurement: "l"
    scan_interval: 60

The resource URL is straight from the mbus-httpd. I had to play around a bit with the proper value_template to extract the one value I am interested in from the JSON-converted XML. HA’s template test page was quite helpful in this respect.

I hope this may be helpful for others, too.



I’d like to read data from my water meter by using M-Bus and then feed HA. Are you aware of any step-by-step guide for the whole setup?



not really, that would be quite a few steps, depending on what you already have in terms of hardware and software. Do you already have an M-bus interface? If yes, which kind?


Thanks for your reply. Actually I’ve realized that my water meter supports wireless M-Bus. I don’t have an interface yet, therefore I’m trying to understand what’s the best approach for my use case.

1 Like


unfortunately I have no experience with wireless M-bus. I suppose once you have a device to read the wirless M-bus, it will be possible to hook that into HA.

Hi, did you find a solution?


I don’t have a final solution yet. On my spare free time I’ve been trying to implement a solution based on ESP32 + CC1101 and this firmware GitHub - chester4444/esp-multical21: ESP8266 decrypts wireless MBus frames from a Multical21 water meter

If that worked fine, data would be available on MQTT.


can you share us your full code in the config yaml?