Esphome ct clamp 30A/1V

Hey everyone,
I am currently trying to get a CT Clamp (SCT013-030) with a Wemos D1 Mini to work. I have set up the following circuit on a breadboard to get some test results:


Unfortunately i am always getting 1,643V on A0. It doesn’t matter how much current is drawn from my test lamp.
Can anyone tell me where my thinking error is?

If you’re using a SCT013-030, it should have an internal burden resistor, which I believe would make R1 unnecessary, IIRC…

R2 and R3 and being used to level shift the the output of the CT (RED) by +1.65V, as the output of the CT will vary from -1V to +1V.

Here is an example wiring diagram I found for a similar SCT013-020 CT. You can see that your “R1” resistor is included inside the CT packaging. Just be sure to not use 5V with an ESP8266 or ESP32. Use the 3.3V as wisely mentioned below my @tom_l.

Note: If you’re using a SCT013 CT that does not output a voltage, but rather outputs a current, you will need the R1 burden resistor shown in your circuit.

4 Likes

Also if using a D1 mini ESP, connect the biasing resistor divider network to 3.3V not 5V.

2 Likes

Good point! I assumed @audacity363 probably knew that already, but better safe than sorry! Edited my post for clarification.

He very likely does, thought I’d mention it just in case.

1 Like

@ogiewon
Thanks for the detailed answer! I did know that the Clap has an resistor inside. So i have now removed mine.
Unfortunately it is the same as before. 1,643 Volts between GND and A0 (with a voltage divider with 10k resistors).

@tom_l
Yes VCC is misleading here. R2 is connected to 3.3V

How are you measuring the voltage? It should average to 1.643VDC, with a 50-60HZ AC signal on top of it. The ESP8266 will need to sample the analog input at very high frequencies to be able to ‘see’ the AC signal and convert it into a power reading.

I just measured it with a multimeter on DC between A0 and GND. After your hint with the frequency I put a small test program on the esp:

esphome:
  name: "test"
  platform: ESP8266
  board: d1

logger:
  level: DEBUG

sensor:
  - platform: ct_clamp
    sensor: adc_sensor
    name: "My Current Sensor"
    update_interval: 10s
  - platform: adc
    pin: A0
    id: adc_sensor
    update_interval: 5s

With that i get the following readings (with a 60 Watt light bulb which should be around 260mA):
With load:

[08:18:43][D][adc:056]: ‘adc_sensor’: Got voltage=0.52V
[08:18:43][D][sensor:092]: ‘adc_sensor’: Sending state 0.52051 V with 2 decimals of accuracy
[08:18:48][D][adc:056]: ‘adc_sensor’: Got voltage=0.52V
[08:18:48][D][sensor:092]: ‘adc_sensor’: Sending state 0.52148 V with 2 decimals of accuracy
[08:18:51][D][ct_clamp:051]: ‘My Current Sensor’ - Raw Value: 0.00A
[08:18:51][D][sensor:092]: ‘My Current Sensor’: Sending state 0.00330 A with 2 decimals of accuracy
[08:18:53][D][adc:056]: ‘adc_sensor’: Got voltage=0.52V
[08:18:53][D][sensor:092]: ‘adc_sensor’: Sending state 0.52148 V with 2 decimals of accuracy
[08:18:58][D][adc:056]: ‘adc_sensor’: Got voltage=0.52V
[08:18:58][D][sensor:092]: ‘adc_sensor’: Sending state 0.52246 V with 2 decimals of accuracy
[08:19:01][D][ct_clamp:051]: ‘My Current Sensor’ - Raw Value: 0.00A
[08:19:01][D][sensor:092]: ‘My Current Sensor’: Sending state 0.00329 A with 2 decimals of accuracy

Without load:

[08:18:08][D][adc:056]: ‘adc_sensor’: Got voltage=0.52V
[08:18:08][D][sensor:092]: ‘adc_sensor’: Sending state 0.52344 V with 2 decimals of accuracy
[08:18:11][D][ct_clamp:051]: ‘My Current Sensor’ - Raw Value: 0.00A
[08:18:11][D][sensor:092]: ‘My Current Sensor’: Sending state 0.00017 A with 2 decimals of accuracy
[08:18:13][D][adc:056]: ‘adc_sensor’: Got voltage=0.52V
[08:18:13][D][sensor:092]: ‘adc_sensor’: Sending state 0.52344 V with 2 decimals of accuracy
[08:18:18][D][adc:056]: ‘adc_sensor’: Got voltage=0.52V
[08:18:18][D][sensor:092]: ‘adc_sensor’: Sending state 0.52344 V with 2 decimals of accuracy
[08:18:21][D][ct_clamp:051]: ‘My Current Sensor’ - Raw Value: 0.00A
[08:18:21][D][sensor:092]: ‘My Current Sensor’: Sending state 0.00015 A with 2 decimals of accuracy
[08:18:23][D][adc:056]: ‘adc_sensor’: Got voltage=0.52V
[08:18:23][D][sensor:092]: ‘adc_sensor’: Sending state 0.52344 V with 2 decimals of accuracy
[08:18:28][D][adc:056]: ‘adc_sensor’: Got voltage=0.52V
[08:18:28][D][sensor:092]: ‘adc_sensor’: Sending state 0.52344 V with 2 decimals of accuracy
[08:18:31][D][ct_clamp:051]: ‘My Current Sensor’ - Raw Value: 0.00A
[08:18:31][D][sensor:092]: ‘My Current Sensor’: Sending state 0.00015 A with 2 decimals of accuracy

1 Like

Hey everyone,

i have now switched to an esp32 to measure three phases (the esp8266 was just for testing while I wait for my order to come in).
After wiring up the following circuit:


and uploading (basically the same as above) a test sketch:

esphome:
  name: "test"
  platform: ESP32
  board: nodemcu-32s

logger:
  level: DEBUG

sensor:
  - platform: ct_clamp
    sensor: adc_sensor
    name: "My Current Sensor"
    update_interval: 10s
  - platform: adc
    pin: GPIO34
    id: adc_sensor
    update_interval: 6s

I am at the same point as with the esp8266:

The ADC sensor always reports 1.10V and the ct clamp sensor 0.00005 A. It doesn’t matter if I turn my light bulb (60W/ 0.240A on 230V) on or off.

2 Likes

You do have the clamp only around the live wire, and not both live and neutral?

Yes. It is just around the live wire. With my clamp meter I can measure the 0.240A.

TBH I didn’t think your setup completely through, but when I saw your 1.10V reading, this immediately reminded me of a similar problem I had getting correct values from that sensor:

I’m not sure why you are getting the 1.10V even when the light bulb is off, but you should keep in mind, that you may just always see the maximum voltage an ESP32 ADC sensor returns with the attenuation set to default.

@audacity363

I also had trouble getting the ESPHome CT sensor to work. I created an issue for it.

I was actually able to get good readings using an ESPHome custom component, as I mentioned in the issue description.

Anyone else using the ESPHome CT sensor and is it working for you?

EDIT: I got it working using this suggestion:

As i´m currently also reading into this - maybe of interest, even if it will not fix the issue:

The ADC in the ESP32 has a range of 0 to 1.1v.
The voltage divider sets the midpoint between 0 and 3.3V (= 1.65v) as a DC bias.
1.65V is higher than the max V of the ADC so its saturated.

The ESP32 has an attenuator, and setting it to 11db may help…

I also had a similar problem, after much investigation it turned out I had the incorrect board configured in ESPhome.

It should be;

esphome:
  name: powermonitor
  platform: ESP8266
  board: d1_mini

It had defaulted to the generic board ‘esp01’

I have been using the CT Clamp for over a year and I recently found that when my load is OFF (no current) I get nan - I think this did not happen in the past but not sure:

[D][ct_clamp:038]: 'Water Boiler Power Power [W]' - Raw AC Value: nanA after 2819 different samples (563 SPS)e
[D][sensor:113]: 'Water Boiler Power Power [W]': Sending state nan W with 1 decimals of accuracye

When It is on it seems to work fine

[D][ct_clamp:038]: 'Water Boiler Power Power [W]' - Raw AC Value: 0.106A after 6120 different samples (1224 SPS)e
[D][sensor:113]: 'Water Boiler Power Power [W]': Sending state 0.10638 W with 1 decimals of accuracye

My code is

  - platform: ct_clamp
    sensor: adc_sensor
    name: "${friendly_name} Power [W]" #" Current [A]"
    unit_of_measurement: "W"
    sample_duration: 5s
    update_interval: 10s
    accuracy_decimals: 1

Any thought?

Sorry to ask this 12 months later - but why not use the 5V? I have set up a test with both 5V and 3.3V and both work. Is it for additional voltage from the CT? (I have measured this in case and it is miniscule)

You want to bias the ADC to half its supply rail voltage(3.3V/2 = 1.65 ) so it can pick up the maximum positive and negative voltage swing, +/- 1.65V. If you use the 5V rail it will be biased to 5/2 = 2.5V, allowing a 2.5V negative swing but only 3.3 - 2.5 = 0.8V positive swing.

If your generated voltage from the CT is small enough you won’t notice any difference. Unless the component uses this 1.65v in it’s calculations. However start generating AC voltages bigger than 0.8V and the positive value will clip, giving erroneous results.

2 Likes

Thanks for the explanation. I’ll have to research some more as I have pretty tenuous grasp.