Route 1: Modbus TCP
- In the M-Center, enter the OBIS code for the required registers. The import tariff 1 reading (1-0:1.8.1) is then at register 1030.
- In Node-RED, add a «Modbus Read» node. Server: IP of the M-Center, port 502, type TCP.
- Unit ID: the Modbus device address of the meter in the M-Center.
- FC 3 (Read Holding Registers), address 1029 for register 1030, quantity 2, poll rate for example 15 minutes.
- Attach a function node that combines the two registers into a floating-point number.
// Two 16-bit registers (big endian, high word first) -> float32
const buf = Buffer.alloc(4);
buf.writeUInt16BE(msg.payload[0], 0);
buf.writeUInt16BE(msg.payload[1], 2);
msg.payload = buf.readFloatBE(0);
msg.topic = "apartment1/import_t1";
return msg;
The manual counts registers from 1, node-red-contrib-modbus expects the address from 0. Hence 1029 for register 1030. Compare the first value with the meter reading in the M-Center.
For several meters, create one read node per meter with its own unit ID. The addresses stay the same as long as the OBIS codes are entered.
Route 2: MQTT
With the MQTT licence, the M-Center publishes every value under its own topic. An «mqtt in» node with a wildcard subscription receives all values of an M-Center:
<prefix>/emu/mcenter/<MAC>/meterreading/#
First attach a debug node and look at the topics and the content of the messages. Then separate the values by topic with a switch node, for example by the OBIS code at the end of the path.
Which route?
| Modbus TCP | MQTT | |
|---|---|---|
| Addresses | fixed, documented in the manual | topic per meter and register |
| Query | Node-RED polls actively | M-Center sends on its own |
| Further systems | a separate query for each system | any number of subscribers on the broker |
| Licence | 210.300.04 | 210.300.03 |