Esp32 and multiple CT Clamp SCT-013 with wrong zero values

Hi all,
i’m going to build an energy monitor for my house.
I am going to use an Azdelivery esp32 devkit c4, it claims to have 16 ADC
Can i attach up to 16 ct clamp?
in emontx i see they do not attach more than 4 clamps, is it only due to the lack of multiple adc?

i’ve built a prototype on a breadboard with one clamp. I’ve got several problems offsetting to zero values when no current flows.
my esp32 always read 0.007 to 0.010 corresponding to 0.5A or 10 to 20W.

[11:25:19][D][ct_clamp:038]: 'PowerMeter Quadro PT Ch 1 Current' - Raw AC Value: 0.825A after 807 different samples (2690 SPS)
[11:25:19][D][sensor:125]: 'PowerMeter Quadro PT Ch 1 Current': Sending state 17.16085 A with 4 decimals of accuracy
[11:25:19][D][sensor:125]: 'ch1_energy': Sending state 4049.96021 W with 0 decimals of accuracy
[11:25:19][D][sensor:125]: 'ch1_total_energy': Sending state 13.89269 kWh with 2 decimals of accuracy
[11:25:21][D][sensor:125]: 'adc_sensor': Sending state 0.14200 V with 2 decimals of accuracy
[11:25:21][D][ct_clamp:038]: 'PowerMeter Quadro PT Ch 1 Current' - Raw AC Value: 0.813A after 826 different samples (2753 SPS)
[11:25:21][D][sensor:125]: 'PowerMeter Quadro PT Ch 1 Current': Sending state 16.91836 A with 4 decimals of accuracy
[11:25:21][D][sensor:125]: 'ch1_energy': Sending state 3992.73193 W with 0 decimals of accuracy
[11:25:21][D][sensor:125]: 'ch1_total_energy': Sending state 13.89491 kWh with 2 decimals of accuracy
[11:25:23][D][sensor:125]: 'adc_sensor': Sending state 0.14200 V with 2 decimals of accuracy
[11:25:23][D][ct_clamp:038]: 'PowerMeter Quadro PT Ch 1 Current' - Raw AC Value: 0.851A after 843 different samples (2810 SPS)
[11:25:23][D][sensor:125]: 'PowerMeter Quadro PT Ch 1 Current': Sending state 17.71147 A with 4 decimals of accuracy
[11:25:23][D][sensor:125]: 'ch1_energy': Sending state 4179.90674 W with 0 decimals of accuracy
[11:25:23][D][sensor:125]: 'ch1_total_energy': Sending state 13.89724 kWh with 2 decimals of accuracy

I’ve already changed the power source thinking it was faulty (from an usb charger to a tenstar robot transformer from 220vac to 3.3dc, the one i will use in production to power esp from main ac).

This is how i’ve attached my esp32

and this is my config. I’m using a lamba to filter out false values.

sensor:
  - platform: homeassistant
    name: "Voltage"
    id: voltage
    entity_id: input_number.sensor_epyc_850va_input_voltage
    internal: true

  - platform: ct_clamp
    sensor: adc_sensor
    name: "${nome_esteso} Ch 1 Current"
    id: ch1_current
    update_interval: $update_interval
    accuracy_decimals: 4
    device_class: current
    filters:
      - calibrate_linear:
        - 0.003 -> 0.0
        - 0.12400 -> 2.569 #measured data
        - 0.22800 -> 4.775 #measured data
        - 0.31700 -> 6.620 #measured data
        - 0.42300 -> 8.800 #measured data
    #dati in W
    on_value:
      then:
        - sensor.template.publish:
            id: ch1_energy
            state: !lambda |-
                      if (id(ch1_current).state > 0.005) { 
                        return (id(ch1_current).state * id(voltage).state); 
                      } else { 
                        return 0.0;
                      };

  - platform: template
    id: ch1_energy
    name: ch1_energy
    lambda: return {};
    unit_of_measurement: W
    accuracy_decimals: 0
    device_class: energy
    state_class: measurement
    
  - platform: adc
    pin: 36
    id: adc_sensor
    attenuation: auto
    update_interval: $update_interval

# Energy Sensors (kWh) for HA Dashboard
  - platform: total_daily_energy
    name: ch1_total_energy
    power_id: ch1_energy
    filters:
      - multiply: 0.001
    unit_of_measurement: kWh
    device_class: energy
    state_class: measurement

    

Last question. How can i manage when the ct clamp is detached?
thanks in advance

Hi,

I’m interested in the result of this, did you solve the problem? Have you tried with multiple clamps? Other comments and concerns?

Regards Björn

No, not if you also want to make use of wifi at the same time

Well the problem with CT clamps (a current meter) is that you can’t just “convert” it to power by multiplying it with the voltage. Without taking the power factor into account you will not be able to get “real” values.

Don’t waste your time with CT clamps/current meters if you are aiming getting power/energy readings.

Interesting, what is a better alternative?

Also, my electric provider (tibber) reports the voltage per phase and the total power factor.

I’m not an expert but I’m guessing that the power factor for the whole house is not relevant if I just measure the amperage with the CT clamp for a specific appliance.

For a accurate whole house consumption probably a/some cheap pzem004t v3 will do the trick.

If you not aware of the power factor on the phase your appliance is running you will stuck with a current measurement. :zap:

Every simple/stupid “smart” plug with power/energy meter function is aware of the power factor (and voltage) otherwise they would be just current meters :wink:

Nice, thanks for the response, really appreciate it! :slight_smile: