Hacky integration for M-Bus

Hello @the78Mole,
is the USB-M-Bus adapter you use in your blog a master or a slave? I already have a master in the M-Bus network. Is your solution capable to sniff on the M-Bus network? Are there cheap solutions to read the Mbus with an existing master?

THX

Yes, you can use it with

I use a master and as far as I know, there is no sniffer solution out there. It was on my to-do list since months, but I had no time for it yet…

Maybe this thing can be useful to sniff?

MBus Monitor

I’ve written a tool in python to poll M-Bus devices and send data automatically to Home Assistant via MQTT.
I’ve just published the code:

Works like a charm for me on an rpi1b+.

Hi and sorry to ask you this. I want to incorporate my Sharky 775 heat meter into HA and came across your post. How exactly did you proceed with the WMBusmeters project and the DVB-T antenna. I am still quite new to HA and would be grateful for any help. Best regards

Let’s forget about TV and use EspHome:

If anybody still search for a wired M-Bus → MQTT Gateway. I’ve already developed one.

It’s an Arduino IDE 2 developed Code for ESPs with a library to communicate Meterbus and one to decode M-Bus.

The HA Autodiscovery Messages will be generate on the fly and you will find the device inside the HA MQTT integration with all records. But you can use every platform if MQTT is supported.

Nearly all meters are supported now.

MBusino → Gateway

MBusinoLib → decoding Lib

MBusCom → the communication Lib…oh I’m a new user and can’t share more as 2 links

If you have questions, ask :stuck_out_tongue_winking_eye:

how decode wired mbus packets ?
68 56 56 68 08 00 72 21 30 58 00 01 06 15 07 DE EC 00 00 0C 78 21 30 58 00 04 6D 34 B5 3D 37 04 13 45 00 00 00 02 3B 00 00 44 13 5A 00 00 00 42 6C 21 37 02 27 84 03 03 FD 17 0C 07 08 04 FF 0A 01 04 04 00 02 FF 0B 00 00 03 FF 0C 85 01 B0 0F 00 05 04 36 FF 00 02 07 03 00 FC 16

Specify your question!

For ā€œone Timeā€ decode:
https://www.miller-alex.de/Mbus

Or try my lib:
https://wokwi.com/projects/402235052803622913

I got it without the library too

captive_portal:
uart:
id: uart_mbus
tx_pin: GPIO17
rx_pin: GPIO16
baud_rate: 2400
parity: EVEN
stop_bits: 1
rx_buffer_size: 1024

debug:
direction: RX
dummy_receiver: true
after:
delimiter: [0x16]
sequence:
- lambda: |-
std::string hex_data;
for (auto b : bytes) {
char buf[6];
sprintf(buf, "%02X ", (uint8_t)b);
hex_data += buf;
}
ESP_LOGI(ā€œmbusā€, ā€œReceived raw M-Bus data: %sā€, hex_data.c_str());

      if (bytes.size() < 50) {
        ESP_LOGW("mbus", "Packet too short");
        return;
      }

      if (bytes[0] != 0x68 || bytes[3] != 0x68) {
        ESP_LOGW("mbus", "Invalid header");
        return;
      }

      if (!(bytes[7] == 0x21 && bytes[8] == 0x30 && bytes[9] == 0x58)) {
        ESP_LOGW("mbus", "Unknown device address");
        return;
      }

      // Kogumaht (Volume) - 4 baiti @ positsioon 33
      if (bytes.size() > 36) {
        uint32_t volume_liters = (uint32_t)bytes[33] |
                                 ((uint32_t)bytes[34] << 8) |
                                 ((uint32_t)bytes[35] << 16) |
                                 ((uint32_t)bytes[36] << 24);
        float volume_m3 = volume_liters / 1000.0f;
        id(apator_volume).publish_state(volume_m3);
        ESP_LOGI("mbus", "Water volume: %.3f m³", volume_m3);
      }

      // Hetkevooluhulk (Flow rate) - 2 baiti @ positsioon 39
      if (bytes.size() > 40) {
        uint16_t flow_lph = (uint16_t)bytes[39] | ((uint16_t)bytes[40] << 8);
        float flow_m3h = flow_lph / 1000.0f;
        id(apator_flow).publish_state(flow_m3h);
        ESP_LOGI("mbus", "Flow rate: %.3f m³/h", flow_m3h);
      }

sensor:

  • platform: template
    name: ā€œApator Water Volumeā€
    id: apator_volume
    unit_of_measurement: ā€œmĀ³ā€
    accuracy_decimals: 3
    update_interval: never

  • platform: template
    name: ā€œApator Flow Rateā€
    id: apator_flow
    unit_of_measurement: ā€œm³/hā€
    accuracy_decimals: 3
    update_interval: never

Hello Everyone,

I created an ESPHome component for interfacing to M-bus metering devices: ESPHome M-bus component

Code quality is not yet merge-worthy (no CI testcases so far, style cleanup needed), but it functionally works.

It is suitable for the use case of reading one or more values from one or more M-bus meters connected to a bus by an ESPHome node acting as the bus master.

It is not suitable for sniffing between a provider’s meter and the provider’s gateway, nor for interfacing to meters speaking DLMS over M-bus.