Packom Pi HAT for Mbus & heat sensors

Has anyone else used this yet? Is now sold by the shop (& direct by Packom). Am toiling to get the heat meter (Sontex 531) to appear in Emonhub inputs. When I added the script from the interfacers page to the hub, I got nothing and the input/feed from the EmonTX3 for a pulse counter was corrupted. The TX3 uses a serial connection between the UART terminals and a USB adaptor to the Pi. Radio can’t be used as the HAT covers the GPIO with no pass through. TheTX3 is powered through this from the Pi with the JP2 jumper removed. AC adaptor also connected.

DS18B20 heat sensors can be attached to the HAT as well. Toiling with this also. It appears a small amount of code needs to be inserted using SSH which requires the SD card being removed to do so. Is this correct or has this been done already on the pre-loaded ‘industrial strength’ card?

Any assistance greatly appreaciated

1 Like

Hi Peter, welcome to the forum.

I’ve got the Packom Hat running on a stock Raspberry Pi 2, running the emonSD-10Nov22 image. This post is more-or-less a summary of the setup process I went through to get it working. I don’t know much about the Emon TX3 though, so hopefully none of what I write here conflicts with how that’s set up.

I’m quite experienced with Linux and embedded systems (I’m an electronics engineer), so I’ve probably glossed over a lot here - happy to clarify anything as required.


After following the steps “Powering On” and “Enabling Serial Access” in the Packom guide (M-Bus Master Hat Instructions –, the process for enabling the BUS power has changed since the guide was written, so here’s how to do that:

One of the GPIO pins needs to be set high to enable to on-board M-Bus power supply, which tripped me up at first. Without doing so, there will be no communication with the M-Bus meter. For newer Raspberry Pi images, this can be done with the terminal command gpioset gpiochip0 26=1.

I’ve added this to at the end of /etc/rc.local so that it happens on power-up of the RPi for convenience.

#!/bin/sh -e
# rc.local
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# bits.
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"

# Update emonpi on first boot if applicable
su pi -c '/opt/openenergymonitor/EmonScripts/update/firstbootupdate'

# Start wifi AP if applicable
#/opt/openenergymonitor/emonpi/wifiAP/ >> /var/log/wifiAP.log

# Enable MBus 36V power
gpioset gpiochip0 26=1

exit 0

The “BUS” LED on the M-Bus hat will illuminate clearly when the power is enabled correctly.

After that, the M-Bus hat uses /dev/ttyAMA0 on my Pi 2 as the serial port (I believe this is the same for other Pi versions, but can’t say for certain), and I’m talking to a Kamstrup 403, so my EmonHub interfacer configuration in emonhub.conf looks like this:

    Type = EmonHubMBUSInterfacer
        device = /dev/ttyAMA0
        baud = 2400
        pubchannels = ToEmonCMS,
        read_interval = 10
        validate_checksum = False
        nodename = heatmeter_oes27
                address = 1
                #type = kamstrup403 
                type = standard


I followed the “M-Bus Master Hat DS” section in the above guide. Then there’s an example interfacer for emonhub.conf here: emonhub/conf/interfacer_examples/DS18B20 at master · openenergymonitor/emonhub · GitHub

You’re probably aware that the DS version of the Packom M-Bus hat has a built-in sensor, so you can experiment with getting this one to work before adding further external sensors.

1 Like

Hi Ben
Thanks for this. I take it that this needs to be done using the Pi directly connected to a screen and keyboard etc using SSH, and cannot be done from Emoncms. I can see no way of opening a command line shell from it. Is this correct?

You’re correct. The only edits that can be done via Emoncms are to the Emonhub configuration.

There is a third option: at least for the M-Bus, in theory (I’ve not tried) it’s possible to make all the configuration changes offline by just editing files on the SD card. But I would consider this to be a more advanced approach. If you’ve got the SD card out, then probably simplest to just enable SSH and do it that way.

Made some progress. Managed to complete the stages on the website. Have also enabled SSH in the raspi-config interfacving options which enable use of PuTTY from my desktop. This will be really useful for cutting and pasting your code.
However, I now have a small challenge with /etc/rc.local - I am unable to access it. See the attached screen grab. It is asking for a password. I have tried emonsd and also the password for emoncms. Neither work. Any idea what I should be using?

Also noticed that in your code for the Emonhub interfacer configuration you have a different node name to that shown in the section on heatmeters on the site page which uses MBUS. Is this a change required when using the Packom HAT?

Thanks in anticipation of your ongoing help.

/etc/rc.local is a configuration file, so you’ll need to use a text editor such as nano or vim in order to make add the required line. E.g. sudo nano /etc/rc.local. It shouldn’t be too hard to find a well written guide or video on how to use these editors - certainly one that’s better than I could write!

Editing /etc/rc.local is one of the final pieces of the puzzle (to keep things working between reboots); have you got all the sensors up and running now?

Worked out over the weekend need to use ‘sudo nano’ and updated all the scripts as provided. Have double checked everything. Still no joy with the mbus meter connection. Shown below is the configuration in emonhub and also a screenshot of using a script by Trystan Lea to check if it is responding. I checked both the baud rate (2400) and the mbus address on the meter itself (address = 0). Have checked the wiring including swapping over the leads on the HAT terminal. I understand they are supposed to be polarity-agnostic so shouldn’t make any difference. Is there something else I have missed?

Have managed to find the heat sensors. Still got a bit of fiddling to do as the one originally attached isn’t working. Will need to check the cable jointing elsewhere. It is around 3m long for an external ambient temp reading. Do you think the internal pull up resistor in the HAT should give sufficient to allow visibility?

Someone please correct me if I’m wrong, but I think (from some reading around, not from experience) that M-Bus address 0 is not valid.

That is to say, address 0 seems to be used for unconfigured devices and that you may want to try configuring your meter for another address (say 1), to avoid this uncertainty.

Still no joy. Changed the address on the Sontex531 to 6. To do this you have to fit a jumper to the board to enable ‘Parameter mode’. Once changes are made, it is then removed.

I noticed this on the attached screen when booting. Is this the possible cause of non connection if it prevents a suitable voltage on the GPIO pin? If so how do I rectify this? Have been back in to /etc/rc.local and everything is exactly as your script earlier in the thread.

You can use this script to set the MDUS address which works without physically touching the meter: usefulscripts/ at master · emoncms/usefulscripts · GitHub

Sorry, I’ve not been following this thread. But here are a couple of scripts I made to get the Packom HAT up and running:

Hi Glyn
Thanks for the reply. You will have to work on the basis I am a complete eejit with some of this stuff. Very often I understand everything. You should see some of the complex formule written for excel during my career!

However despite searching around on the web I cannot find a suitable tutorial on how to use GitHub scripts or where to put them. Tried placing it in /etc/rc.local as the readme seems to suggest. Obviously got this wrong as Emoncms disappeared. Removed what I had put in and it re-appears.

Would really appreciate some gentle coaching to get the thing working.

Have been sent links to books on GitHub, which are not that helpful. Beyond gleaning that greyed text is a command I am no further forward. From the information in the file it states that the scripts be run at start up. It gives nano /etc/rc.local which is where I had inserted the script provided by Ben. (and since removed). Do I insert the python3 /home/pi/mbus-hat-enable/ command followed by the contents of the I have tried this but get no positive result. Have tried this using both USB0 and AMA0 in the Emonhub Config.