OpenEnergyMonitor Community

Reading from multiple MBUS meters with the EmonHub MBUS interfacer

Note: For anyone coming to this post interested in a more introductory post on heat pump monitoring please see the heat pump monitoring guide here: Heat Pump Monitoring - Guide | OpenEnergyMonitor This post documents continued development of the concepts and tools discussed there.

I’ve been putting together a new variant of a heat pump monitor that uses MID metering for both the electrical input and heat output of the heat pump. This particular kit is for Richard Boyd (@boydo).

Rather than use a Modbus reader to read from a SDM120-Modbus meter and an MBUS reader for the heat meter as I had been doing, it is of course possible to use a single MBUS reader to read from more than one MBUS meter (including the MBUS version of the SDM120), which both reduces cost and makes assembly of the kit in an enclosure a bit neater and easier.

To facilitate reading from multiple MBUS meters using an MBUS reader attached to a RaspberryPi 3a running EmonHub, I needed to modify the EmonHubMBUSInterfacer to support reading from multiple meters. This is now working and available for testing in a dedicated development branch of EmonHub called mbus_multiple_meters: GitHub - openenergymonitor/emonhub at mbus_multiple_meters

To use this branch, SSH into your emonSD based RaspberryPi setup, navigate to the emonhub directory and change the branch:

cd /opt/openenergymonitor/emonhub
git pull
git checkout mbus_multiple_meters

Open emonhub.conf in an editor or via the emoncms emonhub config interface

sudo nano /etc/emonhub/emonhub.conf

Change or add a configuration for the MBUS interfacer, the following gives an example for reading from an SDM120-MBUS electricity meter AND Qalcasonic E3 heat meter.

Note that ‘validate_checksum = False’ is required for the SDM120 for some reason as the checksums seem to only be valid occasionally.

The MBUS address of one of thes meters needs to be changed so that each meter is on a unique MBUS address

    Type = EmonHubMBUSInterfacer
        device = /dev/ttyAMA0
        baud = 2400
        pubchannels = ToEmonCMS,
        read_interval = 10
        validate_checksum = False
        nodename = MBUS
                address = 2
                type = sdm120
                address = 1
                type = qalcosonic_e3

Restart emonhub:

sudo systemctl restart emonhub

Test setup

On the desk here I have a Qalcosonic E3 heat meter with MBUS output (courtesy of Richard Boyd) in a test loop so that I can measure water flow, a SDM120-MBUS electricity meter and my RaspberryPi 3a+ based MBUS reader and DS18B20 temperature sensor input development board. Care taken with all of the mains wiring of course.

A closer look at the heat pump monitor board with the MBUS reader sitting on top of a base board that then sits on top of the RaspberryPi 3a+. 2x DS18B20 sensors connect in at the top-right and the MBUS meters connect in just below that (grey wires):

Sensors and USB power disconnected:

I am doing a small run of these MBUS reader and heat pump monitor base boards and can supply these together with an enclosure, gland, RaspberryPi 3a+ and emonSD SD card. If this of interest please contact me via the OpenEnergyMonitor shop email: [email protected] referencing this forum post. As this is a custom item and made to order, the lead times are a bit longer than our usual kit, depending on stock and my availability at the time :slight_smile:

Test output data

Flow and return temperatures and ‘heat output’ as measured using the setup above (the flow temperature sensor is placed in a warm glass of water here for testing):

Electricity consumption measured by the SDM120-MBUS meter and heat meter flow rate:

Heat pump monitoring

If the above was connected up to a heat pump, we could use the emoncms heat pump monitor app to explore the performance of the heat pump in a lot of detail e.g:

Hope that’s interesting or useful for now, I will merge the changes to the EmonHub MBUS interfacer into the master branch soon and update this post once I’ve done that.

The hardware schematic and board file for the heat pump monitor raspberrypi base board can be found here:

and latest version of the schematic and board file for the MBUS reader here:

How to change the MBUS address of a connected meter

Note: Please see post lower down with improved scripts available in the usefulscripts repository Reading from multiple MBUS meters with the EmonHub MBUS interfacer - #5 by TrystanLea

To have more than one meter connected to a single MBUS reader we need to ensure that all meters have a unique address.

It seems that a lot of meters come pre-programmed to be on address 1 to start with.

The following script placed in the home folder on the RaspberryPi with the MBUS reader attached as above can be used to change the address of a connected meter.

Start by connecting only one meter up to the MBUS reader, run this script to move that meter onto address 2. The SDM120-MBUS requires that you press down the button near the LCD in order to place the meter in configuration mode.

Once complete connect up the second MBUS meter, assuming that this meter is on address 1 no further address changes are required as we now have two meters on unique addresses.

import sys, time
from interfacers import *
mbus = EmonHubMBUSInterfacer.EmonHubMBUSInterfacer("MBUS","/dev/ttyAMA0",2400)

old_address = 1
new_address = 2

print ("Sending command to change meter on address "+str(old_address)+" to address "+str(new_address))
mbus.mbus_set_address(old_address, new_address)
reply = False
while mbus.ser.in_waiting:
    val = ord(
    if val==229: 
        reply = True

if not reply:
    print("no reply received")

print ("Sending command to check meter at address "+str(new_address))
mbus.mbus_short_frame(new_address, 0x40)
reply = False
while mbus.ser.in_waiting:
    val = ord(
    if val==229: 
        reply = True

if not reply:
    print("no reply received")

Thanks @TrystanLea amazing work! Looking forward to getting these going on the next batch of houses.

1 Like

I’ve added a couple of scripts to the usefulscripts repository that is included on the emonPi/emonbase/emonSD image to make changing the MBUS address of a connected MBUS meter easier.

Here are the steps to use this script:

  1. Make sure you have an up to date system, run a full update from Admin > Update > Full update

  2. SSH into the Pi (see: Service Credentials - Guide | OpenEnergyMonitor)

  3. Run the script by typing the following command:

python3 /opt/emoncms/modules/usefulscripts/mbus/
  1. The script will for input on the right serial port, baud rate, starting address and new address to enter, you can just hit enter to use the defaults if they are correct, or alternatively enter the relevant values.

    If everything goes to plan you should see an output like this with ACK replies confirming the commands were received and acted on correctly:

Please enter serial port (default: /dev/ttyUSB0):
Please enter baud rate (default: 2400):
Trying to connect on /dev/ttyUSB0 2400
Please enter current address (default: 254):
Please enter new address (default: 1):
Sending command to check meter at address 254
Sending command to change meter on address 254 to address 1
Sending command to check meter at address 1

There’s also a second script just for checking that a meter is responding on a particular address without changing that address, again with input prompts to enter to specify the address etc:

python3 /opt/emoncms/modules/usefulscripts/mbus/
1 Like