Step 1: Telegraf reads via Modbus TCP
Telegraf has a Modbus input plugin. For each meter you create a block with its device address. The example reads import and export of an electricity meter with device address 9:
[[inputs.modbus]]
name = "m_center"
controller = "tcp://192.168.1.50:502"
slave_id = 9
timeout = "5s"
interval = "15m"
holding_registers = [
{ name = "import_total", byte_order = "ABCD", data_type = "FLOAT32-IEEE", scale = 1.0, address = [999, 1000] },
{ name = "export_total", byte_order = "ABCD", data_type = "FLOAT32-IEEE", scale = 1.0, address = [1149, 1150] },
]
[inputs.modbus.tags]
meter = "apartment_1"
Telegraf counts addresses from 0, the manual from 1: register 1000 becomes 999. Byte order ABCD corresponds to big endian with the high word first, as delivered by the M-Center. The notation of the options changes between Telegraf versions; the plugin documentation of your version applies.
Alternative: Telegraf reads via MQTT
With the MQTT licence, Telegraf subscribes to the M-Center’s topics with the plugin inputs.mqtt_consumer:
<prefix>/emu/mcenter/<MAC>/meterreading/+/byobis/#
How Telegraf evaluates the messages is set with data_format. So look at the content of the messages with an MQTT client first.
Step 2: InfluxDB and Grafana
- In Telegraf, set the output to InfluxDB (
outputs.influxdb_v2with URL, token, organisation and bucket). - In Grafana, add InfluxDB as a data source.
- Create a panel and query the reading. For consumption per day or month, take the difference of the meter reading over the time window.
Meter readings only rise. A bar chart with consumption per day is therefore usually more meaningful than the curve of the meter reading.