How can you read a meter with a slave module?
Hi @Oleksii_Zelivianskyi
I want to read my Kamstrup multical 21water meter mbus.
did you fint any usefull solutions ?
Hi all,
This topic is quite old, but it shows up at the top, when asking google about ESPhome and mbus. First, I want to state, that M-Bus and wireless M-Bus are quite different. They look quite similar when it comes to interpretation of the data, but widely used wmBus slaves transfer with T1 and send on their own in regular intervals. (wired) M-Bus slaves need to be polled.
Now to the ESPhome questions:
With wireless M-Bus, I see no easy solution to connect it with some ESP or ESP32. You need another radio module (868 MHz) to receive the data. For USB, there are some more or less cheap USB-to-wmBus-Converters (some use DVB-T-Sticks for it, other like me take the IMST iM871A-USB).
With M-Bus, you need a special circuit to level-shift the master’s TX data and also a part of the circuit to measure the current drawn by the slaves (master’s RX). There exist quite many cuircuits from chinese shops (aliexpress) that sell ready-to-use USB-to-M-Bus-Converters. Nevertheless, I also would find it great, if somebody could address it on some ESP32, maybe I’ll do this sooner or later…
With some Raspberry Pi and the mentioned converters, it is much easier to integrate M-Bus and wmBus meters into Home Assistant or other Smart Home systems.
For further Information, I wrote some stuff on my blog about M-Bus and wmBus, so anybody still interested could read through and if still some stuff is not clear, I would be happy to extend my post or answer questions here:
Hi all,
I had the job to integrate 10 heat meters (Zenner Zelsius C5) into HA. They work over M-Bus (Meter Bus) wireless oder wired. I decided to use wires, since we could reuse some existing wires. They act as M-Bus slaves. All slaves are connected to the M-Bus in a star - topology.
The bus is connected to the Gateway. I use one from ADFweb. I decided to use the M-Bus/MQTT Gateway, because this was for me the easiest possibility to get the sensor values into HA.
I had to view, select and configure the M-Bus Parameters and publish them as MQTT-Topics. The Gateway reads the configured M-Bus data, converts it into MQTT-Topics and publishes it to the MQTT server (Mosquitto) in Home Assistant. From there I can easily configure them as sensors.
It is not the direct way, since I have to configure the sensors twice; but after a long research I found this the best solution for my situation.
As a result I get a nice view for every apparment. Something like this:
@klacol thank you very much for sharing. I am looking for a solution to read my water meters as well.
I have a few questions, maybe you know the answers to?
- I see in the ADFWEB specification that the gateway also has the wi-fi config option:
http://www.adfweb.com/download/filefold/MN67931_ENG.pdf
How are you connecting the gateway to your LAN? via the ethernet cable or wifi? I would like to use the wifi and it is interesting if the connection is stable, etc.
- Do you happen to know if several M-BUS masters/gateways can talk to the same meter/device/slave at the same time? I might have a situation where my water company is querying the devices and I would like to install a personal gateway for my HA as well (my understanding is that there should be no problems?)
Thank you.
There is a link further up to the module I am using, with the caveat that I am connecting to a Kamstrup electricity meter that powers the line. Other MBUS devices may behave differently…
@dknt - could you please update how it went for you? Maybe post a link to what mbus master module you ordered? Is everything working for you now? On Rpi, or maybe on ESP? Thank you!
I checked the price. These ADFweb modules are quite expensive for “home use”…
Modbus_controller has been merged into esphomes dev branch yesterday.
It let’s you connect most modbus RTU devices if you know the modbus registers used by the device.
Documentation is not yet online on esphome.io (but already in the ‘next’ branch.
Until then have a look at
And the staged docs at Modbus Controller — ESPHome
Didn’t know that m-bus is not modbus. Just saw register and got triggered
I am using it via LAN; I cannot say something about the stability of wifi.
As of my understanding, this should not be a problem. You would have two masters (e.g. the Gateway; sorry they have no other word for this over at MBus) and one Slave (the meter; again MBus-Words). The Gateway queries the meters every x seconds.
It would be good, to have this for M-Bus (Meter Bus) too. The both standards (Modbus and M-Bus) are mixed up very often; so I tend to use the term “Meter Bus” for M-Bus.
I have integrated a gas meter to the M-Bus (Meter Bus) with an pulse reader and a pulse counter . Perhaps, this works for water meter as well. The equipment is quite expensive IMHO, but since I am not the electronic engineer, this was my way. It would be much better, when my gas provider would install a meter, that has a digital interface, but in 2021 they still install gas meters as in 1970 :-(.
I’ve linked a quite cheap (35 bucks) M-Bus solution using a cheap USB-M-Bus-Dongle in my blog I already mentioned before. There you only need to add a small bash script to cron that publishes the sensors found in a first run to MQTT and all you need to do is configuring it once in Home Assistant.
Here is the link to the blog post again (for the lazy ones):
If there is heavy interest in some ESP32 M-Bus master (e.g. to use it with ESPhome), I would put it on top of my list of projects to realize in the near future… But the quick and reliable solution is to use the USB-M-Bus-Master from aliexpress…
@the78mole thank you for sharing your solution.
/1./
My preference would really be to have an ESP32/ESPHome solution for reading M-bus meters.
Firstly, because the meters are physically located quite far away from my RPi, and I would not have to pull two m-bus wires all over my apartment.
Secondly - I have an HAOS installation on an RPi (Installation - Home Assistant) which is a managed OS, and I am not sure how to install third party software like libmbus on it.
So ESPHome would (hopefully) solve those two issues for me.
On that note, I have found another project (to the above Snedig’s), which has implemented it:
Have you checked it?
I am just not sure what are its limitations, would it work on other meters than listed, and would it work with an M-Bus Master module, instead of a Slave.
/2./
Since I am looking forward to connecting it to the ESP32, I have ordered an M-bus Master module with TTL serial port from Ali (17EUR): https://www.aliexpress.com/item/33009939864.html?spm=a2g0s.9042311.0.0.27424c4dlVSRON
In real life it looks like this:
However, I haven’t figured out yet if/how it supplies 30V power to the bus. I have hooked up 12VDC to VIN and GND, but I see 0 DC voltage on the MBUS terminals.
The poorly translated specs on Ali don’t say much:
" 7, M: MBUS bus interface, the initial high level bus 30 ± 1V(customizable)"
Messaging with the seller is fruitless because of the language barrier (or the lack of subject knowledge?).
On the other hand I see in the description of your device it states clearly:
- The module takes power from the USB port of the computer and boosts the internal voltage to 36V.
Maybe you happened to measure the voltage across the MBUS terminals of your module? Does it show ~30V right after you hook it up to the USB port? Or maybe it starts feeding 30V only after some event?
Hi paulius,
first of all: Great finding!!!
No, I didn’t stuble over this solution, even if I searched quite a bit for it…
And yes, I’ve measured the voltage on the M-Bus of my adapter (and did it right now again to make myself certain): It is exactly 30.0…30.1V
This part heavily looks like some simple Step-Up-Converter, but unfortunately, I can not read the exact IC part number. But the coil and the pin-count of the IC lead to this conclusion.
The larger 3-pin part on the left (with AGO naming) seems to be the Step-Up switch, which shortens the output coil pin to ground to store energy on the coil and then release it, to store the higher voltage on the Capacitor (10/50V VT). The diode SS16 is the output diode of the step-up (quite a chaotic design )
The two resistors 203 (20K) and 303 (30K) could be selectable feedpack divider parts for changing the output voltage of the step-up converter to the two levels for TX = HIGH/LOW.
So, you should be able to apply e.g. 12V to Vin and you could measure the M-Bus-Voltage at the right pin of the large capacitor (should be 30V). If this is not the case, the step-up converter is not starting. You should find a datasheet for the IC and look out for enable signal, measure it and find the root cause, if it is deactivated.
If I would have a little more time, I could reverse-engineer the design quite easily with your nice foto shots, but unfortunately (as you can see from the time of my post), I’m currently under quite heavy load.
If you can get a more crispy shot of the little IC, I’ll do my best to support further. Some hint: Take the shot with flash and in an angle around 45 degree. The characters will light up when the angle is just right because of very different reflection properties of the ink and the case. Pictures from the top have often very low contrast.
I’ll already ordered one of these TTL-M-Bus master converters, since I’m planning to also get rid of some long M-Bus wires in my house. But it will be delivered around christmas
Hope you can report some success soon.
If we finish this successfully, I’ll extend my blog post (or write a second onw) for all to copy the solution, maybe with some more advanced own hardware.
Thanks for sharing also your findings.
Regards,
Daniel
@the78mole, hi Daniel,
your response has given me the knowledge I did not have and inspired to search deeper for the reasons behind my problems.
In short - I got it working, huge thanks!
The details of my journey:
/1. I checked the voltage on the capacitor as you suggested and got 28V there:
/2. Your text “If this is not the case, the step-up converter is not starting. You should find a datasheet for the IC and look out for enable signal, measure it and find the root cause, if it is deactivated.” has made me do the RTFM and I paid attention to this item in the specs of my MBUS-TTL module:
6, TTLVCC: TTL level voltage input, can not be left floating, you must input TTL level voltage
I have to say I had previously connected ONLY GND and VIN terminals to 14V, leaving others ‘floating’.
Needless to say, connecting all terminals (TTLVCC, RXD, TXD) has solved my problem and I started getting 27.5V on MBUS terminals!
/3. Then I installed libmbus
as per instructions on your blog.
Scanning for connected devices gave some response, which gave hope that some communication is happening, but no meaningful results - i.e. no physical or secondary addresses:
paulius:~/libmbus$ mbus-serial-scan -b 2400 /dev/ttyUSB0
Collision at address 162
Collision at address 168
Collision at address 173
paulius:~/libmbus$ mbus-serial-scan -b 2400 /dev/ttyUSB0
Collision at address 55
paulius:~/libmbus$ mbus-serial-scan -b 2400 /dev/ttyUSB0
Collision at address 0
paulius:~/libmbus$ mbus-serial-scan-secondary -b 2400 /dev/ttyUSB0
I then did RTFM again - I checked the the specs of my heating meter Ista sensonic II mbus
:
It gave me two pointers:
a. by long-pressing the button I can go to the third display loop and find out the M-bus address:
b. detailed info regarding baud rates:
This brought me to the function call:
paulius:~/libmbus$ mbus-serial-request-data -b 300 /dev/ttyUSB0 85
And soon thereafter came the response:
<?xml version="1.0" encoding="ISO-8859-1"?>
<MBusData>
<SlaveInformation>
<Id>16</Id>
<Manufacturer>RKE</Manufacturer>
<Version>105</Version>
<ProductName>Ista sensonic II mbus</ProductName>
<Medium>Heat: Outlet</Medium>
<AccessNumber>226</AccessNumber>
<Status>02</Status>
<Signature>0000</Signature>
</SlaveInformation>
[...]
Scanning for addresses with 300 baud rate gives results:
paulius:~/libmbus$ mbus-serial-scan -b 300 /dev/ttyUSB0
Found a M-Bus device at address 85
–
So now - the “only” thing left is to bring libmbus
libraries to ESPHome?
Once again big thanks for the guidance and hoping you can find some time for that new endeavor.
Hi paulius,
wow, a meter without a secondary address, must be from the century before the last
I’m really happy to see your first problems solved. The migration to ESPhome should be not so hard, since M-Bus itself is quite an easy protocol (upwards the physical layer which get’s complex with more than three meters).
Unfortunately, the name of the step-up-converter did not lead to any result. There exist some MAX848 boost converter, but with a totally different footprint and the voltage output capability is far below the needed 30V. But in fact, it doesn’t matter… It’s a step-up and can be replaced easily with other solutions in an own design.
Regards,
Daniel