We use cookies to optimize site functionality and provide the best possible experience.
View our new Privacy and Protection of Personal Data here.
Accept Settings
< ALL Posts

Send Wireless M-Bus OMS Data to MQTT Server with STG Series

02.01.2025

Updated for firmware 3.00.00 (first published 02.01.2025).

1. Introduction

Wireless M-Bus (M-Bus) is a widely used communication protocol for remote meter reading in smart metering applications. The Open Metering System (OMS) standard ensures interoperability between different manufacturers' devices. When integrating Wireless M-Bus OMS data into an IoT ecosystem, MQTT (Message Queuing Telemetry Transport) is a preferred protocol due to its lightweight and efficient data transmission.

STG Series WMBus Gateways receive Wireless M-Bus (WMBus) telegrams of meters over the air, decrypt and parse them, and make the meter values available as Modbus registers and as MQTT messages. This article shows how to send the meter data to an MQTT broker; the details are in chapter 13 "Sending WMBus Data to an MQTT Server" of the STG user manual.

Prerequisites

Before starting, ensure you have the following:

• A Wireless M-Bus OMS-enabled meter

• An STG series gateway

• An MQTT broker that accepts an unencrypted MQTT connection with user name and password; encrypted MQTT (TLS) is not supported.

• An Ethernet connection between the gateway and the broker (the STG655 can also use its BPL link).

2.Step 1: Setting Up the STG Series Gateway

1. Connect to the gateway: power it up and open its web interface; the abcZ Network Tool finds its address by MAC address.

2. Choose a function that publishes: on the Operating Mode page set Device Function to WMBus Decoder/Parser and MQTT Publisher (MQTT only), or to one of the two Modbus gateway functions if Modbus should run at the same time.

3. Configure WMBus reception: on the WMBus Settings page select Rx Package Reception Mode - S - Mode, T - Mode or C / T - Mode ( combined reception of T and C Mode messages ) - as your meters transmit.

4. Add the meters and their keys: press Refresh Auto Config List, type the AES key of each encrypted meter and save. Each meter needs an enabled row in Device Query Settings on the Operating Mode page; saving with Add to Config creates that row.

5. Decoding is automatic: a meter is published when it has an enabled row and its telegram could be decrypted and decoded.

3. Step 2: Configuring MQTT Communication

1. Open Network Settings. In the Modbus gateway functions tick Enable MQTT Publisher for Parsed WMBus Packages.

2. Enter MQTT Broker IP or URL and MQTT Broker Port (usually 1883).

3. Enter a Client ID that is unique on the broker, then User Name and Password. Both are always sent and cannot be left empty.

4. Enter the Publish Topic (for example meters/wmbus/data) and a Subscribe Topic that belongs to this device only.

5. Choose the Data Format: RAW WMBUS DECRYPTED DATA, PARSED DATA AS OBJECTS or PARSED DATA AS MODBUS FRAME.

6. Set Minimum Send Interval for a Parsed Data (in seconds): the shortest time between two messages of the same meter (factory default 60).

7. Enter the NTP Server IP or URL if the messages should carry time stamps. Save and restart the device (Management page, Reboot Device).

Enable MQTT only when the broker can be reached: while it cannot be reached the gateway restarts after about 13 minutes, and once more after the same time, to recover the connection; after two such restarts in a row it stays up and waits.

4. Step 3: Testing and Monitoring

1. On the gateway: the Device Status page shows MQTT Status APP_MQTT_STATE_SUBSCRIBED when the device is connected to the broker and has subscribed; MQTT Sent Messages counts the published messages.

2. On the broker: use an MQTT client (e.g., Tago.io, MQTT Explorer, Mosquitto_sub) to monitor the topic.

3. Read a message. In PARSED DATA AS OBJECTS each record carries storage number, function, data type and value:

{"STGid":"5A9A","STGNme":"STG_21ea_LAB","Time":"1792047106","RxTm":"1792047106","Data":{"DevId":"19142190","ManId":"9B4","Ver":"13","Typ":"7","RSSI":"-64","AcNu":"58","DtCnt":"2","Blcks":[{"S":"0","F":"1","T":"3","V":"1230"},{"S":"0","F":"1","T":"47","V":"15-10-2026 10:01:00 DST:0"}]}}

Data type 3 is VOLUME l, data type 47 is DATE & TIME; the codes are the same as in the Modbus register map.

4. Compare the values with the meter readings. "Time" and "RxTm" are present only while the gateway has a current time from the NTP server.

NOTE: The message layouts of all three formats, the connection behaviour and configuration over MQTT are described in chapter 13 "Sending WMBus Data to an MQTT Server" of the STG user manual.

5.Conclusion

Integrating Wireless M-Bus OMS data with an MQTT server using the STG series gateway enables seamless remote monitoring and data analytics for smart metering applications. By following the setup steps outlined above, you can efficiently collect, format, and transmit meter data to any MQTT-compatible IoT platform, enhancing automation and decision-making processes.

For further customization, process the messages on the subscriber side of your broker. The gateway connects without TLS (encrypted MQTT is not supported), so a cloud platform that accepts only TLS connections cannot be the gateway's broker directly.

< ALL Posts
LKM Series Electricity Meter Protocol to Modbus Protocol Gateways with MQTT (and LoRaWAN)
LKM Series Electricity Meter Protocol to Modbus Protocol Gateways with MQTT (and LoRaWAN)
STG Series WMBus (Wireless MBus) - Modbus Protocol Gateway with MQTT
STG Series WMBus (Wireless MBus) - Modbus Protocol Gateway with MQTT
TLM Series LoRa Modems and LoRaWAN EndNode Modems
TLM Series LoRa Modems and LoRaWAN EndNode Modems
CKL Series Modbus TCP and RTU Gateways and Serial to Ethernet Gateways
CKL Series Modbus TCP and RTU Gateways and Serial to Ethernet Gateways
BSB Series Industrial Unmanaged Ethernet Switch (with Broadband Power Line)
BSB Series Industrial Unmanaged Ethernet Switch (with Broadband Power Line)
KMK Series Optical Probes for Energy Meters
HUR Series Modbus TCP and RTU Remote I/O Devices with MQTT (and LoRaWAN)
BKV Series Industrial Converters and USB Tools
BKV Series Industrial Converters and USB Tools
BKV Series Industrial Converters and USB Tools
MBC Series IEC62056-21 Protocol Auto Baud Changer
KMK Series Optical Probes for Energy Meters
REDZ Software Solutions
LoRaWAN
LoRaWAN
In today's rapidly digitizing world, IoT (Internet of Things) devices and applications are becoming increasingly prevalent. In this context, long-range wireless communication technologies play a significant role. One such technology that stands out is LoRa, which offers an innovative solution for low-power, long-range wireless communication.
MQTT
MQTT
As the Internet of Things (IoT) continues to grow, the demand for efficient, lightweight, and reliable communication protocols becomes essential. One of the most popular protocols meeting these demands is MQTT (Message Queuing Telemetry Transport).
Broadband Power Line (BPL)
Broadband Power Line (BPL)
Broadband Powerline Technology (BPL), also known as Powerline Communication (PLC), represents a revolutionary approach to data transmission, leveraging the existing electrical power infrastructure to deliver broadband internet connectivity.
Wireless MBus (WMBus)
Wireless MBus (WMBus)
In an era defined by connectivity and data-driven decision-making, the need for efficient and reliable metering solutions has never been greater. Enter Wireless M-Bus (Meter-Bus) technology, a versatile and robust platform designed to revolutionize remote meter reading and data communication in utility management systems.
IEC62056-21 (for Electricity Meters)
IEC62056-21 (for Electricity Meters)
IEC 62056-21 is an international standard for communication with electricity meters. Developed by the International Electrotechnical Commission (IEC), this protocol standardizes the way data is exchanged between meters and various devices or systems, ensuring interoperability and efficient data management.
DLMS/COSEM (for Electricity Meters)
DLMS/COSEM (for Electricity Meters)
DLMS/COSEM (Device Language Message Specification / Companion Specification for Energy Metering) is the global standard for smart energy metering. It provides a highly secure, interoperable framework for reading and managing energy data across diverse utility networks.
P1 Companion Standard (for Electricity Meters)
P1 Companion Standard (for Electricity Meters)
Smart energy meters have become essential in monitoring and controlling energy usage. To facilitate better integration, communication, and functionality of these smart meters, standards are crucial. One such standard, particularly relevant in Europe, is the P1 Companion Standard.
Modbus RTU
Modbus RTU
Modbus RTU is a widely recognized and utilized communication protocol in the field of industrial automation. Developed by Modicon (now Schneider Electric) in 1979, it was designed to facilitate communication between various electronic devices, primarily programmable logic controllers (PLCs).
Modbus TCP
Modbus TCP
Modbus TCP, also known as Modbus TCP/IP, is a widely adopted communication protocol in the industrial automation sector. It was developed to enable Modbus communication over Ethernet networks, combining the reliability and simplicity of the Modbus protocol with the versatility of Ethernet.
LoRa RF Communication
LoRa RF Communication
LoRa stands for Long Range and is a proprietary wireless modulation technique developed by Semtech. Essentially, LoRa is the physical layer, or the hardware, that allows long-range communication between devices.
MBus
MBus
M-Bus (Meter-Bus) is a robust European standard specifically designed for the remote reading of utility meters, such as electricity, gas, water, and heat. It utilizes a simple, polarity-independent two-wire system that transmits both data and power over long distances, making it highly cost-effective and immune to industrial noise.