ESP32 and SCT013

Hi,
As many others, I have also tried to follow these instructions to set up a power meter.
https://docs.openenergymonitor.org/electricity-monitoring/ct-sensors/how-to-build-an-arduino-energy-monitor-measuring-current-only.html

Unfortunately, I always get the (almost) same reading. I have already tried 3 sct013 sensors and always have the same result. The log below started with little things on, and then I switched on the kettle, air con and electric car charger. I have the sensor plug in the live cable in the main board of the house.

I am using a SCT013 50A/1V
I have tried both a pair of 20k and 10k resistors.

My code:

substitutions:
  device_name: sensor223-test
  friendly_name: test
  ipaddress: 192.168.1.223
  measure_obj: air_con_1
  timeupdate: 5s

esphome:
  name: ${device_name}
  platform: ESP8266
  board: nodemcuv2

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: ${ipaddress}
    gateway: 192.168.1.1
    subnet: 255.255.255.0
  #use_address: sensor206-bath1

logger:
  level: DEBUG
api:
  encryption: 
    key: !secret enc_key
ota:
  password: !secret ota_password

web_server:
  port: 80



sensor:
  - platform: ct_clamp
    sensor: ${measure_obj}
    name: "Measured Current"
    update_interval: ${timeupdate} 
    id: ${measure_obj}_current   #Measured in ampere (I)
    
  # Example source sensor
  - platform: adc
    pin: A0
    id: ${measure_obj}
    
  - platform: template
    id: ${measure_obj}_power
    name: "Measured Power"
    lambda: return id(${measure_obj}_current).state * 230 ; #Power = V*I/1000. So change 230V to whatever your mains voltage is)
    unit_of_measurement: 'W'
    update_interval: ${timeupdate}

my breadboard:

and my log
[09:41:34][D][sensor:124]: ‘Measured Power’: Sending state 0.15632 W with 1 decimals of accuracy
[09:41:38][D][ct_clamp:037]: ‘Measured Current’ - Raw AC Value: 0.001A after 65 different samples (325 SPS)
[09:41:39][D][sensor:124]: ‘Measured Current’: Sending state 0.00067 A with 2 decimals of accuracy
[09:41:39][D][sensor:124]: ‘Measured Power’: Sending state 0.15376 W with 1 decimals of accuracy
[09:41:43][D][ct_clamp:037]: ‘Measured Current’ - Raw AC Value: 0.001A after 59 different samples (295 SPS)
[09:41:43][D][sensor:124]: ‘Measured Current’: Sending state 0.00067 A with 2 decimals of accuracy
[09:41:44][D][sensor:124]: ‘Measured Power’: Sending state 0.15520 W with 1 decimals of accuracy
[09:41:48][D][ct_clamp:037]: ‘Measured Current’ - Raw AC Value: 0.001A after 64 different samples (320 SPS)
[09:41:48][D][sensor:124]: ‘Measured Current’: Sending state 0.00068 A with 2 decimals of accuracy
[09:41:49][D][sensor:124]: ‘Measured Power’: Sending state 0.15632 W with 1 decimals of accuracy
[09:41:53][D][ct_clamp:037]: ‘Measured Current’ - Raw AC Value: 0.001A after 54 different samples (270 SPS)
[09:41:53][D][sensor:124]: ‘Measured Current’: Sending state 0.00068 A with 2 decimals of accuracy
[09:41:54][D][sensor:124]: ‘Measured Power’: Sending state 0.15613 W with 1 decimals of accuracy
[09:41:58][D][ct_clamp:037]: ‘Measured Current’ - Raw AC Value: 0.001A after 66 different samples (330 SPS)
[09:41:58][D][sensor:124]: ‘Measured Current’: Sending state 0.00068 A with 2 decimals of accuracy
[09:41:59][D][sensor:124]: ‘Measured Power’: Sending state 0.15584 W with 1 decimals of accuracy
[09:42:01][D][sensor:124]: ‘air_con_1’: Sending state 0.00000 V with 2 decimals of accuracy
[09:42:03][D][ct_clamp:037]: ‘Measured Current’ - Raw AC Value: 0.001A after 64 different samples (320 SPS)
[09:42:03][D][sensor:124]: ‘Measured Current’: Sending state 0.00068 A with 2 decimals of accuracy
[09:42:04][D][sensor:124]: ‘Measured Power’: Sending state 0.15742 W with 1 decimals of accuracy
[09:42:08][D][ct_clamp:037]: ‘Measured Current’ - Raw AC Value: 0.001A after 68 different samples (340 SPS)
[09:42:08][D][sensor:124]: ‘Measured Current’: Sending state 0.00069 A with 2 decimals of accuracy
[09:42:09][D][sensor:124]: ‘Measured Power’: Sending state 0.15758 W with 1 decimals of accuracy
[09:42:13][D][ct_clamp:037]: ‘Measured Current’ - Raw AC Value: 0.001A after 60 different samples (300 SPS)
[09:42:13][D][sensor:124]: ‘Measured Current’: Sending state 0.00068 A with 2 decimals of accuracy
[09:42:14][D][sensor:124]: ‘Measured Power’: Sending state 0.15723 W with 1 decimals of accuracy
[09:42:18][D][ct_clamp:037]: ‘Measured Current’ - Raw AC Value: 0.001A after 69 different samples (345 SPS)
[09:42:18][D][sensor:124]: ‘Measured Current’: Sending state 0.00066 A with 2 decimals of accuracy
[09:42:19][D][sensor:124]: ‘Measured Power’: Sending state 0.15275 W with 1 decimals of accuracy
[09:42:23][D][ct_clamp:037]: ‘Measured Current’ - Raw AC Value: 0.001A after 57 different samples (285 SPS)
[09:42:23][D][sensor:124]: ‘Measured Current’: Sending state 0.00067 A with 2 decimals of accuracy
[09:42:24][D][sensor:124]: ‘Measured Power’: Sending state 0.15423 W with 1 decimals of accuracy
[09:42:28][D][ct_clamp:037]: ‘Measured Current’ - Raw AC Value: 0.001A after 59 different samples (295 SPS)
[09:42:28][D][sensor:124]: ‘Measured Current’: Sending state 0.00069 A with 2 decimals of accuracy
[09:42:29][D][sensor:124]: ‘Measured Power’: Sending state 0.15853 W with 1 decimals of accuracy
[09:42:33][D][ct_clamp:037]: ‘Measured Current’ - Raw AC Value: 0.001A after 72 different samples (360 SPS)
[09:42:33][D][sensor:124]: ‘Measured Current’: Sending state 0.00068 A with 2 decimals of accuracy
[09:42:34][D][sensor:124]: ‘Measured Power’: Sending state 0.15685 W with 1 decimals of accuracy
[09:42:38][D][ct_clamp:037]: ‘Measured Current’ - Raw AC Value: 0.001A after 73 different samples (365 SPS)
[09:42:40][D][sensor:124]: ‘Measured Current’: Sending state 0.00066 A with 2 decimals of accuracy
[09:42:40][D][sensor:124]: ‘Measured Power’: Sending state 0.15174 W with 1 decimals of accuracy
[09:42:43][D][ct_clamp:037]: ‘Measured Current’ - Raw AC Value: 0.001A after 68 different samples (340 SPS)
[09:42:43][D][sensor:124]: ‘Measured Current’: Sending state 0.00068 A with 2 decimals of accuracy
[09:42:44][D][sensor:124]: ‘Measured Power’: Sending state 0.15661 W with 1 decimals of accuracy
[09:42:48][D][ct_clamp:037]: ‘Measured Current’ - Raw AC Value: 0.001A after 62 different samples (310 SPS)
[09:42:48][D][sensor:124]: ‘Measured Current’: Sending state 0.00068 A with 2 decimals of accuracy

I was playing with this late last year and got it working, but right now that project is on the back burner so it’s not fresh in my mind. I do recall getting similar results to what you’re seeing, and that I had to measure the current with a meter to do the calibration. You could also use a load with a known current draw instead of measuring with a meter.

Hopefully someone with more experience will come along with a better answer, but meanwhile, here’s the configuration which worked for me:

# Source sensor:
  - platform: adc
    pin: GPIO34
    name: "Load1 ADC Sensor"
    id: load1_adc_sensor
    update_interval: 1s
    attenuation: auto

# Sensor to display calculated current
  - platform: ct_clamp
    sensor: load1_adc_sensor
    name: "Load1 Current"
    id: load1_current
    update_interval: 1s
    filters:
      - calibrate_linear:
          # Measured value of 0 maps to 0A
          - 0.0 -> 0.0
          # Known load: 9.3A
          # Value shown in logs: 0.03567A
          - 0.03567 -> 9.3

Hi,
I did the calibration, get the same constant values but closer to real numbers. note that you get 0.03567A and I get 0.00066A, 100 times smaller.