For me the addresses looks all wrong. If L1-N and L2-N are both two registers long the addresses muste be have an offset of 2. I had strange values at large consumption.
This is my working yaml file:
modbus:
- name: zaehler
type: tcp
host: XXX.XXX.XXX.XXX
port: 502
sensors:
- name: L1-N
unit_of_measurement: V
slave: 1
address: 0
input_type: input
data_type: int32
scale: 0.1
precision: 2
swap: word
count: 2
device_class: voltage
- name: L2-N
unit_of_measurement: V
slave: 1
address: 2
data_type: int32
scale: 0.1
precision: 2
swap: word
device_class: voltage
- name: L3-N
unit_of_measurement: V
slave: 1
address: 4
data_type: int32
scale: 0.1
precision: 2
swap: word
device_class: voltage
- name: L12
unit_of_measurement: V
slave: 1
address: 6
data_type: int32
scale: 0.1
precision: 2
swap: word
device_class: voltage
- name: L23
unit_of_measurement: V
slave: 1
address: 8
data_type: int32
scale: 0.1
precision: 2
swap: word
device_class: voltage
- name: L31
unit_of_measurement: V
slave: 1
address: 10
data_type: int32
scale: 0.1
precision: 2
swap: word
device_class: voltage
- name: L1
unit_of_measurement: A
slave: 1
address: 12
input_type: input
data_type: int32
scale: 0.001
precision: 2
swap: word
count: 2
device_class: current
- name: L2
unit_of_measurement: A
slave: 1
address: 14
data_type: int32
scale: 0.001
precision: 2
swap: word
device_class: current
- name: L3
unit_of_measurement: A
slave: 1
address: 16
data_type: int32
scale: 0.001
precision: 2
swap: word
device_class: current
- name: Bezug Netz
unit_of_measurement: kWh
slave: 1
address: 52
data_type: int32
scale: 0.1
precision: 2
swap: word
device_class: energy
state_class: total
- name: Einspeisung Netz
unit_of_measurement: kWh
slave: 1
address: 78
data_type: int32
scale: 0.1
precision: 2
swap: word
device_class: energy
state_class: total
- name: Leistung L1
unit_of_measurement: W
slave: 1
address: 18
data_type: int32
scale: 0.1
precision: 2
swap: word
device_class: power
- name: Leistung L2
unit_of_measurement: W
slave: 1
address: 20
data_type: int32
scale: 0.1
precision: 2
swap: word
device_class: power
input_type: input
- name: Leistung L3
unit_of_measurement: W
slave: 1
address: 22
data_type: int32
scale: 0.1
precision: 2
swap: word
device_class: power
input_type: input
- name: Leistung Gesamt
unit_of_measurement: W
slave: 1
address: 40
data_type: int32
scale: 0.1
precision: 2
swap: word
count: 2
device_class: power
At first, thank you for sharing your code!
Its running without any problem on my own network.
One additional question:
I have to add the frequency data.
But its not working.
Tested with swap none, byte, word.
So i have used the followed code snipped.
totally new to modbus, and need a hint on interfacing.
My setup will be Wallbox Copper SB <–> Carlo Gavazzi EM340.
How do the modbus-serial or modbus-ethernet interface? The wallbox will probably be Master and the EM340 will be at address 1. What is the interface then? Address 2? Or address-less promiscous listener?
name: L1-N
unit_of_measurement: V
slave: 1
address: 0
input_type: input
data_type: int32
scale: 0.1
precision: 2
swap: word
device_class: voltage
name: L2-N
unit_of_measurement: V
slave: 1
address: 2
data_type: int32
scale: 0.1
precision: 2
swap: word
device_class: voltage
name: L3-N
unit_of_measurement: V
slave: 1
address: 4
data_type: int32
scale: 0.1
precision: 2
swap: word
device_class: voltage
name: L12
unit_of_measurement: V
slave: 1
address: 6
data_type: int32
scale: 0.1
precision: 2
swap: word
device_class: voltage
name: L23
unit_of_measurement: V
slave: 1
address: 8
data_type: int32
scale: 0.1
precision: 2
swap: word
device_class: voltage
name: L31
unit_of_measurement: V
slave: 1
address: 10
data_type: int32
scale: 0.1
precision: 2
swap: word
device_class: voltage
name: L1
unit_of_measurement: A
slave: 1
address: 12
input_type: input
data_type: int32
scale: 0.001
precision: 2
swap: word
device_class: current
name: L2
unit_of_measurement: A
slave: 1
address: 14
data_type: int32
scale: 0.001
precision: 2
swap: word
device_class: current
name: L3
unit_of_measurement: A
slave: 1
address: 16
data_type: int32
scale: 0.001
precision: 2
swap: word
device_class: current
name: Reference network
unit_of_measurement: kWh
slave: 1
address: 52
data_type: int32
scale: 0.1
precision: 2
swap: word
device_class: energy
state_class: total
name: Feeding into the network
unit_of_measurement: kWh
slave: 1
address: 78
data_type: int32
scale: 0.1
precision: 2
swap: word
device_class: energy
state_class: total
name: Power L1
unit_of_measurement: W
slave: 1
address: 18
data_type: int32
scale: 0.1
precision: 2
swap: word
device_class: power
name: Power L2
unit_of_measurement: W
slave: 1
address: 20
data_type: int32
scale: 0.1
precision: 2
swap: word
device_class: power
input_type: input
name: Power L3
unit_of_measurement: W
slave: 1
address: 22
data_type: int32
scale: 0.1
precision: 2
swap: word
device_class: power
input_type: input
name: Total power
unit_of_measurement: W
slave: 1
address: 40
data_type: int32
scale: 0.1
precision: 2
swap: word
device_class: power
What am I doing wrong here? I removed some of the count variables “count: 2” to get it working. Please help.