Modbus with Carlo Gavazzi EM24

Hello.

I am trying to configurate some sensors of my electricity meter.

My hardware is a Carlo Gavazzi EM24… which is connected to a Modbus/TCP converter.

I need the modbus register of the EM24.

Is here somebody who has already installed it?

Thank you a lot.

2 Likes

im also stuck with this… did you get it to work?

I got it work. Here you can find my yaml.

modbus:
  - name: zaehler
    type: tcp
    host: x.x.x.x
    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: 1
        data_type: int32
        scale: 0.1
        precision: 2
        device_class: voltage
      - name: L3-N
        unit_of_measurement: V
        slave: 1
        address: 3
        data_type: int32
        scale: 0.1
        precision: 2
        device_class: voltage
      - name: L12
        unit_of_measurement: V
        slave: 1
        address: 5
        data_type: int32
        scale: 0.1
        precision: 2
        device_class: voltage
      - name: L23
        unit_of_measurement: V
        slave: 1
        address: 7
        data_type: int32
        scale: 0.1
        precision: 2
        device_class: voltage
      - name: L31
        unit_of_measurement: V
        slave: 1
        address: 9
        data_type: int32
        scale: 0.1
        precision: 2
        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: 13
        data_type: int32
        scale: 0.001
        precision: 2
        device_class: current
      - name: L3
        unit_of_measurement: A
        slave: 1
        address: 15
        data_type: int32
        scale: 0.001
        precision: 2
        device_class: current
      - name: Gesamt
        unit_of_measurement: kWh
        slave: 1
        address: 61
        data_type: int32
        scale: 0.1
        precision: 2
        device_class: energy
        state_class: total
      - name: W L1
        unit_of_measurement: W
        slave: 1
        address: 17
        data_type: int32
        scale: 0.1
        precision: 2
        device_class: power
      - name: W L2
        unit_of_measurement: W
        slave: 1
        address: 19
        data_type: int32
        scale: 0.1
        precision: 2
        device_class: power
        input_type: input
      - name: W L3
        unit_of_measurement: W
        slave: 1
        address: 21
        data_type: int32
        scale: 0.1
        precision: 2
        device_class: power
        input_type: input
      - name: momentanE
        unit_of_measurement: W
        slave: 1
        address: 39
        data_type: int32
        scale: 0.1
        precision: 2
        count: 2
        device_class: power
2 Likes

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
1 Like

You need check hex values in debug log

To see if you need swap or not, etc

It is interesting because my yaml file is also working.

Where should I check hex values in debug log? Can you explain it please?

Thank you

logger:
  logs:
    homeassistant.components.modbus: debug
    pymodbus.client: debug

configuration.yaml

Thanks. I have added it but under Configuration/Log I can`t find any entries?

Supervisor logs

Or in /config/

Hi Martin, all

here is a sample of my config which is working except for sometimes some neg. values when high power is consumed.

Mike

EM24-E1

modbus:

  • name: EM24eth
    type: tcp
    host: 192.168.X.XX
    port: 502
    timeout: 5
    delay: 3
    sensors:

    • name: PG-L1-N
      unit_of_measurement: V
      address: 0x0000
      count: 1
      slave: 30
      precision: 2
      scale: 0.1
      device_class: voltage

    • name: PG-L2-N
      unit_of_measurement: V
      address: 0x0002
      count: 1
      slave: 30
      precision: 2
      scale: 0.1
      device_class: voltage

    • name: PG-W-L1
      unit_of_measurement: W
      address: 0x0012
      count: 1
      slave: 30
      precision: 2
      scale: 0.1
      scan_interval: 5
      device_class: power

    • name: PG-Import-Total
      unit_of_measurement: kWh
      address: 0x0112
      count: 1
      slave: 30
      precision: 2
      scale: 0.1
      device_class: energy

    • name: PG-Export-Total
      unit_of_measurement: kWh
      address: 0x0116
      count: 1
      slave: 30
      precision: 2
      scale: 0.1
      device_class: energy

Hi there.

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.

- name: EM24_Frequency
        unit_of_measurement: Hz
        slave: 1
        address: 55
        input_type: input
        data_type: int16
        scale: 0.1
        precision: 2
        swap: none
        device_class: frequency

Maybe somebody can give me a hint what i’m doing wrong…

Two further power data are working great.
Maybe somebody have to add these, too:

- name: EM24_P Scheinl Aktuell
        unit_of_measurement: VA
        slave: 1
        address: 42
        data_type: int32
        scale: 0.1
        precision: 2
        swap: word
        count: 2
        device_class: power
      - name: EM24_P Blindl Aktuell
        unit_of_measurement: VAr
        slave: 1
        address: 44
        data_type: int32
        scale: 0.1
        precision: 2
        swap: word
        count: 2
        device_class: power

Hi all,

this is my Frequency Implementation:

BR

Mike

# PG - Frequency

    - name: PG-Frequency
      unit_of_measurement: Hz
      address: 0x0033
      count: 1
      slave: 30
      precision: 2
      scale: 0.1

Hi all,

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?

Marek

1 Like

Did you get this to work? I’m looking for a way to copy the data from my Garlo Gavazzi EM330 connected to Wallbox Pulsar MAX

It’s not working with a EM24-E1-AV5 X

i would expect at least some data for L1-N

modbus:

  • name: Carlo Gavazzi EM24
    type: tcp
    host: 192.168.023.050
    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
      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.

[quote=“Tueftler, post:11, topic:353336”]

  - name: Carlo_Gavazzi_EM24
    type: tcp
    host: 10.10.10.215
    port: 502
    sensors:
      - name: L1-N
        slave: 1
        address: 0
        unit_of_measurement: V
        device_class: voltage
        state_class: measurement
        scale: 0.1
        offset: 0
        precision: 2
        data_type: int32
        unique_id: L1-N
        swap: word
      - name: L2-N
        slave: 1
        address: 2
        unit_of_measurement: V
        device_class: voltage
        state_class: measurement
        scale: 0.1
        offset: 0
        precision: 2
        data_type: int32
        unique_id: L2-N
        swap: word
      - name: L3-N
        slave: 1
        address: 4
        unit_of_measurement: V
        device_class: voltage
        state_class: measurement
        scale: 0.1
        offset: 0
        precision: 2
        data_type: int32
        unique_id: L3-N
        swap: word
      - name: L1-L2
        unit_of_measurement: V
        slave: 1
        address: 6
        data_type: int32
        scale: 0.1
        precision: 2
        device_class: voltage
        unique_id: L1-L2
        swap: word
      - name: L2-L3
        unit_of_measurement: V
        slave: 1
        address: 8
        data_type: int32
        scale: 0.1
        precision: 2
        device_class: voltage
        unique_id: L2-L3
        swap: word
      - name: L3-L1
        unit_of_measurement: V
        slave: 1
        address: 10
        data_type: int32
        scale: 0.1
        precision: 2
        device_class: voltage
        unique_id: L3-L1
        swap: word
      - name: L1
        unit_of_measurement: A
        slave: 1
        address: 12
        data_type: int32
        scale: 0.001
        precision: 2
        device_class: current
        unique_id: L1
        swap: word
      - name: L2
        unit_of_measurement: A
        slave: 1
        address: 14
        data_type: int32
        scale: 0.001
        precision: 2
        device_class: current
        unique_id: L2
        swap: word
      - name: L3
        unit_of_measurement: A
        slave: 1
        address: 16
        data_type: int32
        scale: 0.001
        precision: 2
        device_class: current
        unique_id: L3
        swap: word
      - name: Reference network
        unit_of_measurement: kWh
        slave: 1
        address: 52
        data_type: int32
        scale: 0.1
        precision: 2
        device_class: energy
        state_class: total
        unique_id: Reference_network
        swap: word
      - name: Feeding into the network
        unit_of_measurement: kWh
        slave: 1
        address: 78
        data_type: int32
        scale: 0.1
        precision: 2
        device_class: energy
        state_class: total
        unique_id: Feeding_into_the_network
        swap: word
      - name: Power L1
        unit_of_measurement: W
        slave: 1
        address: 24
        data_type: int32
        scale: 0.1
        precision: 2
        device_class: power
        unique_id: Power_L1
        swap: word
      - name: Power L2
        unit_of_measurement: W
        slave: 1
        address: 26
        data_type: int32
        scale: 0.1
        precision: 2
        device_class: power
        input_type: input
        unique_id: Power_L2
        swap: word
      - name: Power L3
        unit_of_measurement: W
        slave: 1
        address: 28
        data_type: int32
        scale: 0.1
        precision: 2
        device_class: power
        input_type: input
        unique_id: Power_L3
        swap: word
      - name: Total power
        unit_of_measurement: W
        slave: 1
        address: 42
        data_type: int32
        scale: 0.1
        precision: 2
        device_class: power
        unique_id: Total_Power
        swap: word
      - name: Frequency
        unit_of_measurement: Hz
        slave: 1
        address: 51
        input_type: input
        data_type: int16
        scale: 0.1
        precision: 2
        device_class: frequency
        unique_id: Frequency
        swap: word

You’re welcome :slight_smile: