element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi Projects
  • Products
  • Raspberry Pi
  • Raspberry Pi Projects
  • More
  • Cancel
Raspberry Pi Projects
Blog MBUS Master Hat for Raspberry Pi
  • Blog
  • Documents
  • Events
  • Polls
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi Projects to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: hwhardsoft
  • Date Created: 27 Oct 2023 2:21 PM Date Created
  • Views 1043 views
  • Likes 6 likes
  • Comments 0 comments
  • mbus
  • meterbus
  • raspberrypi
  • smartmeter
Related
Recommended

MBUS Master Hat for Raspberry Pi

hwhardsoft
hwhardsoft
27 Oct 2023
how to add meterbus to the Raspberry Pi

Due to rising prices for oil, gas and heat as well as climate change, it is becoming more and more important to monitor energy consumption in order to keep an eye on energy costs, but also to be able to check the effectiveness of savings. Many meters for oil and gas, but also for water, are equipped with a special bus system, the M-BUS or meter bus, for monitoring consumption values.

This article describes how such meters can be read out via the M-BUS interface using a special M-BUS HAT.

image

A special interface is required to connect the Raspberry Pi to the M-BUS. The HAT in our example uses the UART interface of the Raspberry Pi.

{gallery}My Gallery Title

image

MBUS HAT for Raspberry Pi

image

Features:

  • M-Bus (Meter-Bus) Master
  • powered by an external 9..30V DC voltage (36V for the MBUS will be generated internally from this voltage)
  • up to 6 unit loads can be powered
  • isolated interface
  • selectable UART via jumper (with Raspberry Pi 4 only)
  • indicator LEDs for RX and TX
  • removable block terminal for bus connection
  • stackable headers version

Jumper configuration:

First we have to put the jumpers for the selected UART on the HAT. All older Raspberry Pi models only have the UART0. Only the Raspberry Pi 4 has up to 5 UARTs.

image

UART(0) configuration

The easiest way is to use the raspi-config tool to enable the UART to the GPIO14/15 pins.

Take a fresh Raspbian Bullseye image. Open the console window and enter the following commands:

sudo raspi-config

goto '3 Interfacing Options'

goto 'I6 Serial Port'

'Would you like a login shell to be accessible over serial?' --> NO

'Would you like the serial port hardware to be enabled?' --> YES

Finish raspi-config

sudo echo "dtoverlay=disable-bt" | sudo tee -a /boot/config.txt
sudo systemctl disable hciuart

reboot the Raspberry Pi

Now you can access the UART via /dev/serial0

UART3-5 Configuration (for Raspberry Pi 4 only):

The Raspberry Pi-4 features additional hardware UART ports. The M-BUS HAT can use the additional UARTS 3 – 5. You can enable the additional UARTs by editing the /boot/config.txt file:

sudo nano /boot/config.txt

For UART3 add the following line at the end of the file:

dtoverlay=uart3

If you want to enable more or another UART change this line to uart4 or uart 5 or add some additional lines.

Using libmbus (C++) library and utility:

Libmbus by Raditex Control is an open-source library for Linux.

Installation:

sudo apt-get install -y cmake
sudo git clone https://github.com/rscada/libmbus.git
cd libmbus
sudo ./build.sh
sudo make install
cd bin
sudo ln -s /usr/local/lib/libmbus.so.0 /usr/lib/libmbus.so.0

Usage for UART0:

./mbus-serial-scan -d -b 2400 /dev/serial0

(will list all connected M-Bus slave devices)

./mbus-serial-request-data -d -b 2400 /dev/serial0 10

(will read out the M-Bus device with address 10)

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube