kWh meter using s0 output

Can anyone point me in the right direction for using 3x kWh meters, with s0 output, to monitor power output of my solar panels?
They pulse at 1000 pulses / kWh

I found this:

sensor:
  - platform: pulse_counter
    pin: GPIO12
    unit_of_measurement: 'kW'
    name: 'Power Meter'
    filters:
      - multiply: 0.06

but i also need total kWh per day

hi Sander,

I’ve also been working on this but still not getting it working to recieve the correct data.

My KWH meter is doing 0,5Wh/puls so that should be 2000 pulses per KWh.

To show dat hourly, daily, weekly and monthly you can simply add this to your configuration.yaml:

utility_meter:
  zonnepanelen_kwartier:
    source: sensor.zonnepanelen_kwh
    cycle: quarter-hourly
  zonnepanelen_uur:
    source: sensor.zonnepanelen_kwh
    cycle: hourly
  zonnepanelen_dag:
    source: sensor.zonnepanelen_kwh
    cycle: daily
  zonnepanelen_week:
    source: sensor.zonnepanelen_kwh
    cycle: weekly
  zonnepanelen_maand:
    source: sensor.zonnepanelen_kwh
    cycle: monthly

With you config above the sensor.zonnepanelen_kwh should be pulse_counter.

If anyone has the golden tip it’s very welcome :wink:

Hey Sander,

I’m in the same situation…could you tell me what hardware is needed (esp32,…) and how you assembled it and connected it to the s0 output’s ?

Thanks !

I use an ESP32 for it, because it has a hardware pulse counter (the ESP8622 can “only” count by software):

This is the main part of my code:

esphome:
  name: esp-esp32-nodemcu-2
  platform: ESP32
  board: nodemcu-32s
  comment: Pulse Counter Strom WP

wifi:
  ssid: "ssid"
  password: "pass"
  use_address: esp-esp32-nodemcu-2.domain

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

sensor:
  - platform: pulse_counter
    pin: GPIO27
    unit_of_measurement: 'W'
    accuracy_decimals: 1
    name: 'el. Leistung WP Heizstab ESP'
    update_interval: 3min
    filters:
      - multiply: 30
    total:
      unit_of_measurement: 'kWh'
      accuracy_decimals: 1
      name: 'Stromzaehler WP Heizstab ESP'
      filters:
        - multiply: 0.0005
  - platform: wifi_signal
    name: "ESP ESP32 NodeMCU 2 WLAN Signal"
    update_interval: 60s

Wiring is pretty easy, one the ground, one to GPIO27 (if I remember correctly, only one polarity works - either you try or you read the manual of the power meter :slight_smile: )

Works pretty good here for about a year now.

Oh, super…herzlichen Dank !

Some questions :

Schermafbeelding 2022-08-23 114207

Probably some stupid questions for you, but I like to be sure before jumping into it :wink:

Should work with every ESP32 I think, but I don’t have experience with exactly this board

Phone adapter etc should work, yes. You can also power it from a 5V power adapter like this:
https://www.voelkner.de/products/1288629/

Yes. I’m reading 4 power meters at the moment, no problem. Documentation says: “a maximum of 8 channels can be used”

No, nothing needed in between (besides the cable :slight_smile: )

Nice !

Do you perhaps have a link for the cables between ESP32 en S0 (the ones on a roll) ?

I just used some 0.75 mm² cable I already had at home. But a thinner cable would be sufficient as there is almost no current on that line…

OK, I’ve got some laying around here too…

We order and wait patiently for the delivery…

Thanks for the help and will keep you posted!

OK, I wil start :slight_smile:

But first a question : what means multiply: 30 and multiply: 0.0005 in your code ?

The power meter sends 2.000 pulses per kWh => one pulse is 0.0005 kWh.

1 pulse/min would be 60*0.0005 kWh = 0.03 kWh per hour => 0.03 kWh/h = 0.03 kW = 30 W
=> I need a factor of 30 to get W from the pulses per minute

Thank you for this explanation, now it makes sense…mine is 1000 pulses per kWh :slight_smile:

Meanwhile I did the installation and it works :yum:

  - platform: pulse_counter
    pin: GPIO25
    id: t1
    unit_of_measurement: 'W'
    accuracy_decimals: 1
    name: 'Solar Panel Power Counter 1'
    update_interval: 1s
    filters:
      - multiply: 60    
    # - multiply: 0.06 gives kW
    total:  
      unit_of_measurement: 'kWh'
      accuracy_decimals: 1
      name: 'Solar Panel Energy Counter 1'
      id: t1_total
      filters:
        - multiply: 0.001

I changed the update interval to 1 s, because I want real-time…
I created a helper with the actual value of the physical counter (I have 3 counters), which I use in an new sensor :

- sensor:
    - name: Energy Solar Panel 1
      state: "{{ ((states('sensor.solar_panel_energy_counter_1') | float(0)) + (states('input_number.number_solar_panel_1') | float(0))) | round(1) }}"
      unit_of_measurement: "kWh"
      state_class: total_increasing
      device_class: energy

And made a total sensor:

    - name: Energy Solar Panels
      state: "{{ (states('sensor.energy_solar_panel_1') | float(0) + states('sensor.energy_solar_panel_2') | float(0) + states('sensor.energy_solar_panel_3') | float(0)) | round(1) }}"
      unit_of_measurement: "kWh"
      state_class: total_increasing
      device_class: energy

And in order not to fill up the statistics, I created this sensor (which I then use in the energy dashboard):

- trigger:
    - platform: time_pattern
      minutes: "/5"
  sensor:
    - name: Energy Solar Panels Recorder
      state: "{{ states('sensor.energy_solar_panels') }}"
      unit_of_measurement: "kWh"
      state_class: total_increasing
      device_class: energy

Is this the way to go ?

I’m not sure that will work. Ony for 3600 W you will get a pulse every second. So I’d expect e.g. when you are at 1000 W, you will get 0 W for some seconds and 3600 W for some seconds.
With an update interval of 10s, you get a resolution of 360 W. So, it depends on the values you want to measure.

Good comment, thank you!

The rest of my code a good approach ?

Hi Christian, all works well? Could I ask you the code used for manage 3x EM10-DIN ?

I was doing the same with Arduino, connected like this:
S1 (called also 21): 5 V
S0 (called also 20): Pin8, with additional pull down resistence 10kOhm
Is it required pull down resistence with EPS32?