The program receives and decodes C1,T1 or S1 telegrams (using the wireless mbus protocol) to acquire utility meter readings. The readings can then be published using MQTT, curled to a REST api, inserted into a database or stored in a log file.
Using an dongle, then make sure the binaries exists and are executable:
-
/usr/bin/rtl_sdr
-
/usr/bin/rtl_wmbus
$ git clone https://github.com/weetmuts/wmbusmeters.git
$ cd wmbusmeters
$ make && make test
$ make install
# example for testing
$ cd wmbusmeters/build_debug/
$ wmbusmeters --debug --t1 rtlwmbus watermeter1 izar 20eec43b NOKEY
make install
installs the files:
## files
/usr/sbin/wmbusmetersd
/etc/systemd/system/wmbusmeters.service
/etc/udev/rules.d/99-wmbus-usb-serial.rules
/etc/logrotate.d/wmbusmeters
## directories
/etc/wmbusmeters.d
/var/log/wmbusmeters/meter_readings
You can trigger a reload of the config files with sudo killall -HUP wmbusmetersd
$ cd wmbusmeters/build_debug/
$ wmbusmeters --debug --t1 rtlwmbus diehl izar 43410778 NOKEY
# with config files
$ wmbusmeters --debug --useconfig=/root/.config/wmbusmeters
$ cd /
wmbusmeters --debug --t1 rtlwmbus diehl izar 43410778 NOKEY
wmbusmeters --debug --useconfig=/root/.config/wmbusmeters
$ tail -f /var/log/syslog
$ tail -f /root/log/wmbusmeters/wmbusmeters.log
Check the config file nano /etc/wmbusmeters.conf
and edit the device to point to your dongle.
loglevel=normal
device=rtlwmbus:rtl_sdr -f 868.95M -s 1.6e6 - 2>/dev/null | rtl_wmbus
logtelegrams=true
format=json
meterfiles=/var/log/wmbusmeters/meter_readings
meterfilesaction=overwrite
meterfilesnaming=name
meterfilestimestamp=hour
logfile=/var/log/wmbusmeters/wmbusmeters.log
shell=/usr/bin/mosquitto_pub -h localhost -p 1883 -t tele/wasser/verbrauch -m "$METER_JSON"
Then add a meter file in nano /etc/wmbusmeters.d/diehl
name=watermeter
type=izar
id=FFFF0778
key=
nano /lib/systemd/system/wmbusmeters.service
[Unit]
Description="wmbusmeters service (no udev trigger)"
Documentation=https://github.com/weetmuts/wmbusmeters
Documentation=man:wmbusmeters(1)
After=network.target
[Service]
Type=forking
# Run ExecStartPre with root-permissions
PermissionsStartOnly=true
ExecStartPre=-/bin/mkdir -p /var/log/wmbusmeters/meter_readings
ExecStartPre=/bin/chown -R wmbusmeters:wmbusmeters /var/log/wmbusmeters
ExecStartPre=-/bin/mkdir -p /run/wmbusmeters
ExecStartPre=/bin/chown -R wmbusmeters:wmbusmeters /run/wmbusmeters
ExecStart=/usr/sbin/wmbusmetersd /run/wmbusmeters/wmbusmeters.pid
PIDFile=/run/wmbusmeters/wmbusmeters.pid
[Install]
WantedBy=multi-user.target
nano /lib/systemd/system/[email protected]
[Unit]
Description="wmbusmeters service on %I"
Documentation=https://github.com/weetmuts/wmbusmeters
Documentation=man:wmbusmeters(1)
After=network.target
[Service]
Type=forking
ExecStart=/usr/sbin/wmbusmetersd --device='%I' /run/wmbusmeters/wmbusmeters-%i.pid
PIDFile=/run/wmbusmeters/wmbusmeters-%i.pid
[Install]
WantedBy=multi-user.target
$ sudo systemctl daemon-reload
$ systemctl start wmbusmeters
$ systemctl status wmbusmeters
$ systemctl start wmbusmeters@-dev-rtlsdr_5
$ systemctl status wmbusmeters@-dev-rtlsdr_5
$ systemctl enable wmbusmeters
$ systemctl enable wmbusmeters@-dev-rtlsdr_5
# $ systemctl stop wmbusmeters
# $ systemctl start wmbusmeters
# $ systemctl restart wmbusmeters
# $ systemctl status wmbusmeters
# $ systemctl stop wmbusmeters@-dev-rtlsdr_5
# $ systemctl start wmbusmeters@-dev-rtlsdr_5
# $ systemctl restart wmbusmeters@-dev-rtlsdr_5
# $ systemctl status wmbusmeters@-dev-rtlsdr_5
Wmbusmeters should start automatically, check with
$ tail -f /var/log/syslog
$ tail -f /var/log/wmbusmeters/wmbusmeters.log
>>> Result
(meter) watermeter: probably not for me since received media 0x18 does not match
(izar) log "telegram=|1944A511780743434418A2|411A001312DDB7F5CC3D3A2F35B3D7|+1730"
(wmbusmeters) shutting down
(wmbusmeters) logging started 2020-07-19 06:34:40
(wmbusmeters) waiting for telegrams
(wmbusmeters) logging started 2020-07-19 06:34:46
(wmbusmeters) waiting for telegrams
(wmbusmeters) shutting down
(meter) watermeter: probably not for me since received media 0x18 does not match
(izar) log "telegram=|1944A511780743434418A2|011A001312810AD360BA754859D7DD|+20"
(meter) watermeter: probably not for me since received media 0x18 does not match
(izar) log "telegram=|1944A511780743434418A2|711A001312E4C62F315F4E455898D0|+80"
(meter) watermeter: probably not for me since received media 0x18 does not match
(izar) log "telegram=|1944A511780743434418A2|111A00131296259ACB9BA69182CEDF|+97"
(meter) watermeter: probably not for me since received media 0x18 does not match
(izar) log "telegram=|1944A511780743434418A2|211A001312AF544036F9D2FBEFE5D8|+105"
(meter) watermeter: probably not for me since received media 0x18 does not match
(izar) log "telegram=|1944A511780743434418A2|411A001312DDB7F5CC3D3A2F35B3D7|+122"
(meter) watermeter: probably not for me since received media 0x18 does not match
(izar) log "telegram=|1944A511780743434418A2|511A001312CA98BC671CE9F6EEAAD5|+131"
If not you will see the error message (rtlwmbus) error: when starting as daemon, wmbusmeters expects /usr/bin/rtl_sdr to exist!
and the daemon will refuse to start.)