Energy Tracking - CT Clamp Current Sensor

So I have used CT Clamp Current Sensor and can read current successfully in HA.

For energy tracking I thought I might be able to get power and feed that into the Integration - Riemann sum integral.

First puzzle, in ESPhome

  - platform: template
    name: "Power DB"
    lambda: return 240 * id(current_sensor).state;

I am trying to multiply the current by 240 (Vac) but the answer I get isnt right, I mean in HA I can see a current of say 2.2 A but the power is around 127 Watts. What am I missing?

Secondly, if I feed Power DB into the integration, it doesn’t show up in the energy monitor.

Appreciate any pointers or signposting to learn how to add a CT on ESPPhome into the energy monitor.

Have a look here maybe it will help

Thank you, that looks like it would work if I can figure out how to turn amps to watts, all new to this,

lambda: return 240 * id(current_sensor).state;

just does not seem to be multiplying the current x 240… with current steady as just over 2A I get a number of around 127 - not 480?

  - platform: ct_clamp
    sensor: current_sensor
    name: "Measured Current"
    update_interval: 60s
      - calibrate_linear:
          - 0 -> 0
          - 0.00404 -> 2.2

  - platform: adc
    pin: A0
    id: current_sensor
  - platform: template
    name: "Power DB"
    accuracy_decimals: 2
    lambda: return 240 * id(current_sensor).state;

Have a look at post 24 here, your need you use return x

thank you so much, this is the sort of example I have been looking for! Appreciate your time, David.

  - platform: homeassistant
    name: "Voltage"
    entity_id: sensor.tz3000_r6buo8ba_ts011f_0f8e0060_electrical_measurement_rms_voltage
    id: voltage
    internal: true
  - platform: ct_clamp
    sensor: adc_sensor
    id: home_current
    name: "Measured Current"
    update_interval: 5s
      - calibrate_linear:
           - 0.00049 -> 0.000
           - 0.00098 -> 0.435           
           - 0.00118 -> 0.474
           - 0.00178 -> 0.670
           - 0.00418 -> 1.428
           - 0.00795 -> 2.710

  - platform: adc
    pin: A0
    id: adc_sensor

  - platform: template
    id: my_power
    name: "Home Power"
    lambda: return id(home_current).state * id(voltage).state;
    device_class: power
    unit_of_measurement: 'W'
    update_interval: 5s

  - platform: total_daily_energy
    name: "Total Daily Energy"
    power_id: my_power
        - multiply: 0.001
    unit_of_measurement: kWh
    accuracy_decimals: 3
    icon: mdi:clock-alert
    device_class: energy

  - platform: sntp
    id: my_time

This is my yaml file and all look working fine but if I compare with my portable display which I got with my smart meter, readings not match at all. Is not even close. 1220W (display) 1380W (home assistant), 290W (display) 530W (ha). It looks like when load is higher difference is going down and when load is going down - difference is going up.
I calibrated using hair dryer and tuya smart plug which is showing actual current. Now clamp is around my life main wire by power supply. Hardware: CT Clamp SCT-013-000 100A:50mA, CT Clamp Current Sensor and mini D1.
Any ideas why is not accurate?

Can it be enough to know the rms voltage and the current at the same time without taking the power factor into account to be able to distinguish between active (kW) and reactive (kVAR) power? :thinking:

Doesn’t the rms voltage and current only allow you to get the apparent (kVa) power? :zap:

That would be a indication that you only measure the apparent power and not the active power that you are pay for :money_with_wings:

The change is rather high that when you use a higher power device that it has a “better” power factor. Maybe even resistive load like a heating element that has a power factor of :one: (apparent power = active power in that case :bulb:)

I have the same issue and yes, it has something to do with the POWER FACTOR.
My question is: how can I “fix” the math in the esphome yaml file to take this in account?

I have an arduino sketch that uses some RMS libraries that gave me the right readings, but I really dont know how to move the code (and libraries) from arduino to Esphome…
any idea?

I’m quite confident that you will not be able to calculate the “real” power just with a current meter. What you need is simply a real power meter (like a $10 pzem004t v3 for example). Your current sensor will only deliver amperage :zap:

what if I have the power factor and voltage from modbus power meter on the main line? Could I just use those with ct clamps ?

What update frequency we are talking about? It will probably never be as accurate as a standalone solution (like a $10 pzem004t v3) but if your modbus reads the power factor and voltage every 50 or 100ms and you can do the same with your current meter it might be “sufficient” :person_shrugging:

For me the problem with PZEM-004T is that you need too many wires if you have a lot of them. E.g for 10 units that would set you at 66€. But that’s a lot of additional wires for each(2 ac supply + 4 for rs) which would make it a wiring nightmare

Ah this is modbus, so can probably chain then. The only issue then adding smaller ct and calibrating them

Yes :white_check_mark:

Not supported AFAIK as they pzem004t are factory calibrated :x: