Community
OpenEnergyMonitor

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

[[MBUS]]
    Type = EmonHubMBUSInterfacer
    [[[init_settings]]]
        device = /dev/ttyAMA0
        baud = 2400
    [[[runtimesettings]]]
        pubchannels = ToEmonCMS,
        read_interval = 10
        validate_checksum = False
        nodename = MBUS
        [[[[meters]]]]
            [[[[[sdm120]]]]]
                address = 2
                type = sdm120
            [[[[[qalcosonic]]]]]
                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: HeatpumpMonitor/Hardware/hpmon_pi_baseboard at master · openenergymonitor/HeatpumpMonitor · GitHub

and latest version of the schematic and board file for the MBUS reader here:
HeatpumpMonitor/Hardware/USB_to_MBUS at master · openenergymonitor/HeatpumpMonitor · GitHub

How to change the MBUS address of a connected meter

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
sys.path.append('/opt/openenergymonitor/emonhub/src')
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)
time.sleep(1.0)
reply = False
while mbus.ser.in_waiting:
    val = ord(mbus.ser.read(1))
    if val==229: 
        print("ACK")
        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)
time.sleep(1.0)
reply = False
while mbus.ser.in_waiting:
    val = ord(mbus.ser.read(1))
    if val==229: 
        print("ACK")
        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