MyPi MBUS Card Configuration

The ISO-MBUS adapter board uses the serial lines on pins 32/33

The following line needs to be added to /boot/config.txt to enable UART0 to appear on the correct pins for the adapter card :

dtoverlay=uart0,txd1_pin=32,rxd1_pin=33

This enables /dev/ttyAMA0

Next we need to download and compile the latest version of the mbus utils from the git repo below, this contains demo programs for reading serial and TCP based devices :

https://github.com/rscada/libmbus/

wget https://github.com/rscada/libmbus/archive/master.zip

If not aready installed the following packages should be installed before continuing:

apt-get install build-essential libtool autoconf m4

 

After unzipping the source code follow the installation instructions by running the commands below:

# ./build.sh
# make install

You may also make a symlink for the libmbus library to allow the installed binaries to run, run the below if you get an error problem.

ln -s /usr/local/lib/libmbus.so.0 /lib/libmbus.so.0

MBus serial requires the master (us) to provide the line voltage, you can either supply this from an external source and link into to the card or use the internal 34V PSU. To use the internal PSU make the 34V OUT to 34V IN link on the IO connector.

The card/PSU should be adequate to drive 1-3 slaves without problem.

Note that the mbus serial utils do not have an option to deal with parity, so ensure the comms settings within the meter being used have the parity option set to "None" or "N" or you'll get no reply or errors from the bus.

The baud rate for the mbus util commands can be specified via the -b option, see the man pages for more info, the default is 9600.

Here's a sample interaction with a power meter:

root@raspberrypi:/opt/libmbus/libmbus-master#  mbus-serial-scan /dev/ttyAMA0
Found a M-Bus device at address 10
^C

root@raspberrypi:/opt/libmbus/libmbus-master#  mbus-serial-request-data -b 9600 /dev/ttyAMA0 10
<!--?xml version="1.0" encoding="ISO-8859-1"?-->
<mbusdata>
    <slaveinformation>
        <id>99999999</id>
        <manufacturer>___</manufacturer>
        <version>1</version>
        <productname></productname>
        <medium>Electricity</medium>
        <accessnumber>85</accessnumber>
        <status>00</status>
        <signature>0000</signature>
    </slaveinformation>

    <datarecord id="0">
        <function>Instantaneous value</function>
        <storagenumber>0</storagenumber>
        <unit>Energy (10 Wh)</unit>
        <value>0</value>
        <timestamp>2016-04-22T17:52:50</timestamp>
    </datarecord>

    <datarecord id="1">
        <function>Instantaneous value</function>
        <storagenumber>0</storagenumber>
        <unit>Energy (10 Wh)</unit>
        <value>0</value>
        <timestamp>2016-04-22T17:52:50</timestamp>
    </datarecord>

    <datarecord id="2">
        <function>Instantaneous value</function>
        <storagenumber>0</storagenumber>
        <unit>Energy (10 Wh)</unit>
        <value>0</value>
        <timestamp>2016-04-22T17:52:50</timestamp>
    </datarecord>

    <datarecord id="3">
        <function>Instantaneous value</function>
        <storagenumber>0</storagenumber>
        <unit>Energy (10 Wh)</unit>
        <value>0</value>
        <timestamp>2016-04-22T17:52:50</timestamp>
    </datarecord>

    <datarecord id="4">
        <function>Instantaneous value</function>
        <storagenumber>0</storagenumber>
        <unit>Energy (10 Wh)</unit>
        <value>0</value>
        <timestamp>2016-04-22T17:52:50</timestamp>
    </datarecord>

    <datarecord id="5">
        <function>Instantaneous value</function>
        <storagenumber>0</storagenumber>
        <unit>Energy (10 Wh)</unit>
        <value>0</value>
        <timestamp>2016-04-22T17:52:50</timestamp>
    </datarecord>

    <datarecord id="6">
        <function>Instantaneous value</function>
        <storagenumber>0</storagenumber>
        <unit>Unrecognized VIF extension: 0x3a</unit>
        <value>0</value>
        <timestamp>2016-04-22T17:52:50</timestamp>
    </datarecord>

    <datarecord id="7">
        <function>Instantaneous value</function>
        <storagenumber>0</storagenumber>
        <unit>Unrecognized VIF extension: 0x3a</unit>
        <value>0</value>
        <timestamp>2016-04-22T17:52:50</timestamp>
    </datarecord>

    <datarecord id="8">
        <function>Instantaneous value</function>
        <storagenumber>0</storagenumber>
        <unit>Unrecognized VIF extension: 0x3a</unit>
        <value>0</value>
        <timestamp>2016-04-22T17:52:50</timestamp>
    </datarecord>

    <datarecord id="9">
        <function>Instantaneous value</function>
        <storagenumber>0</storagenumber>
        <unit>Unrecognized VIF extension: 0x3a</unit>
        <value>0</value>
        <timestamp>2016-04-22T17:52:50</timestamp>
    </datarecord>

    <datarecord id="10">
        <function>Instantaneous value</function>
        <storagenumber>0</storagenumber>
        <unit>Unrecognized VIF extension: 0x3a</unit>
        <value>0</value>
        <timestamp>2016-04-22T17:52:50</timestamp>
    </datarecord>

    <datarecord id="11">
        <function>Instantaneous value</function>
        <storagenumber>0</storagenumber>
        <unit>Unrecognized VIF extension: 0x3a</unit>
        <value>0</value>
        <timestamp>2016-04-22T17:52:50</timestamp>
    </datarecord>

</mbusdata>



Contact us now to discuss your project

Ready to order, contact us today for pricing or samples

Contact Us