Esphome ct clamp 30A/1V

Resistors create a voltage divider of half, so 3.3 * .5 = 1.65V ish for a biased input. Bias is used so you can measure the full -1V - +1V AC swing of the CT clamp, basically 1.65V is now acting as 0, bias - 1V = 0.65V and bias + 1V = 2.65V. The ADC can’t measure negative voltages, Tom explained it with images above.

The capacitor is used as a decoupling capacitor to filter out any HF noise and to stabilize the 1.65V biased input to the CT clamp. If noise were to get into the input, it could taint the readings.

1 Like

Ah I see. Thanks.

I was under the impression that both the bias and attenuation were done internally by the ESP32 board and needed to be configured on ESPHome

The attenuation is set in the ADC sensor. The bias is created by the voltage divider and stabilized by the decoupling capacitor.

1 Like

Hi everyone,

I was just curious what would the result be if I didn’t use the voltage divider and filter capacitor. I understand the reasoning behind them after reading through several threads including this one. But before I did, I simply hooked up my CT which does have a built in burden resistor. 200a/3vac. Initially I just used the single analog pin on the esp8266 and ground and it seemed to work just fine with no additional components. I then added an ads1115 to add a second CT channel, which also seemed to work ok, however I’m now wondering if my values are not as sensitive as they could be? Because it seems like it could be better. By not shifting the input up do I lose half the resolution I would normally have? With a 1amp load on my CT the resulting raw value the esp8266 reads is approx 0.015a (3V/200a)=0.015 which to me seems correct unless I’m missing something.

my take away on all these clamp projects I’ve tried is your clamp needs to be close to the load

if you’re measuring a one amp load with a 30 amp clamp you will get a lot of negatives and or just bad readings.

it was not obvious to me at first but a 5amp/1v clamp means at 5 amp it will read one volt

all that said I purchased a tuya 30 amp CT clamp and it seems to measure one amp fairly well

I agree a 200a CT is much to large for a 1a load typically speaking.
My project will ultimately be my grid mains panel which is why it’s 200a. I was just testing on the bench for now. I also tested with a 10a load and it seemed in line with the 1a load.
Like I mentioned everything seems to work perfectly fine as it is except i was hoping for a bit more accuracy, in particular I have 2 CT’s setup on the same wire and they seem to vary slightly during a constant load test. This could be due to what you mentioned about me testing a 1amp load on such a large CT.
I’m rounding up some resistors and a capacitor to try my exact setup the “proper” way with the voltage divider to see if in fact my accuracy increases. Or if it yields the same results.

I really think you need a 5 amp CT clamp on the workbench to build your confidence

but waiting two weeks for AliExpress takes all the fun out of it

I have a probably dumb question but anyways…

I am trying to follow the Digiblur design here GitHub - digiblur/digiDryerMon: ESP8266 based washer/dryer current monitoring via a split core current transformer over MQTT along with the diagrams here and other ones I see in the network like this one from here:

An the dumb question is, which cables are the ones connected there between the PIN 34 and the 3.3V ? Because the CT Clamp comes with a TRS cable with 3 lines, but in all diagrams I see just 2 being used.

Here I also just see a 2 lines input for the CT Clamp.

In this comment Esphome ct clamp 30A/1V - #9 by audacity363, the cables are labelled “Clamp White” and “Clamp Red” that means there is no GND connection to the clamp and it just floats?

Thank you in advance.

Edit:

As reference, I did not cut the connector that came with the CT Clamp but bought a TRS female connector to make the connection.

Here with a soldered hard cable to test on a breadboard first:

I have no idea how to discover which cable do I have to use without destroying the cable (which I really want to avoid)

It will be difficult what color scheme your TRS cable is following unless you find that shared by your cable manufacturer. Take a plain 3.5 mm male jack and multimeter and find the TIP, Ring and Sleeve.

The datasheet for the clamp has the info !!

1 Like

This helps! The tip and the ring are what we need to use. so I will just check which cables are those. If they are like regular audio cables, it is probably the red and black ones.

Thanks!

I am having problems reading my values. If I connect directly the output of the voltage divider to the analog input of the ESP32 I get an stable 1.6V read on the ADC, but as soon as I connect it to the clamp circuit the voltage starts to go up and down from 0.14x volts to 3.1x volts

See the logs

[09:57:00][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 0.14200 V with 3 decimals of accuracy

[09:57:02][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 0.975A after 741 different samples (1235 SPS)

[09:57:02][D][sensor:094]: 'Measured Current': Sending state 0.97464 A with 2 decimals of accuracy

[09:57:06][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 0.14200 V with 3 decimals of accuracy

[09:57:08][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 0.972A after 736 different samples (1226 SPS)

[09:57:08][D][sensor:094]: 'Measured Current': Sending state 0.97248 A with 2 decimals of accuracy

[09:57:12][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 0.14200 V with 3 decimals of accuracy

[09:57:14][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 0.976A after 743 different samples (1238 SPS)

[09:57:14][D][sensor:094]: 'Measured Current': Sending state 0.97649 A with 2 decimals of accuracy

[09:57:18][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 2.65200 V with 3 decimals of accuracy

[09:57:20][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 0.981A after 742 different samples (1236 SPS)

[09:57:20][D][sensor:094]: 'Measured Current': Sending state 0.98115 A with 2 decimals of accuracy

[09:57:24][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 1.63100 V with 3 decimals of accuracy

[09:57:26][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 0.980A after 748 different samples (1246 SPS)

[09:57:26][D][sensor:094]: 'Measured Current': Sending state 0.98016 A with 2 decimals of accuracy

[09:57:30][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 2.70300 V with 3 decimals of accuracy

[09:57:32][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 0.977A after 741 different samples (1235 SPS)

[09:57:32][D][sensor:094]: 'Measured Current': Sending state 0.97730 A with 2 decimals of accuracy

[09:57:36][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 0.45800 V with 3 decimals of accuracy

[09:57:38][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 0.979A after 747 different samples (1245 SPS)

[09:57:38][D][sensor:094]: 'Measured Current': Sending state 0.97947 A with 2 decimals of accuracy

[09:57:42][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 3.15500 V with 3 decimals of accuracy

[09:57:44][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 0.974A after 738 different samples (1230 SPS)

[09:57:44][D][sensor:094]: 'Measured Current': Sending state 0.97374 A with 2 decimals of accuracy

[09:57:48][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 2.61600 V with 3 decimals of accuracy

[09:57:50][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 0.976A after 743 different samples (1238 SPS)

[09:57:50][D][sensor:094]: 'Measured Current': Sending state 0.97550 A with 2 decimals of accuracy

[09:57:54][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 2.60700 V with 3 decimals of accuracy

[09:57:56][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 0.975A after 740 different samples (1233 SPS)

[09:57:56][D][sensor:094]: 'Measured Current': Sending state 0.97488 A with 2 decimals of accuracy

[09:58:00][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 2.37500 V with 3 decimals of accuracy

[09:58:02][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 0.986A after 748 different samples (1246 SPS)

[09:58:02][D][sensor:094]: 'Measured Current': Sending state 0.98600 A with 2 decimals of accuracy

[09:58:06][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 2.19200 V with 3 decimals of accuracy

[09:58:07][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 0.980A after 746 different samples (1243 SPS)

[09:58:08][D][sensor:094]: 'Measured Current': Sending state 0.97967 A with 2 decimals of accuracy

[09:58:12][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 2.06700 V with 3 decimals of accuracy

[09:58:14][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 0.977A after 741 different samples (1235 SPS)

[09:58:14][D][sensor:094]: 'Measured Current': Sending state 0.97657 A with 2 decimals of accuracy

[09:58:18][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 2.13500 V with 3 decimals of accuracy

[09:58:20][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 0.978A after 746 different samples (1243 SPS)

[09:58:20][D][sensor:094]: 'Measured Current': Sending state 0.97769 A with 2 decimals of accuracy

[09:58:24][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 0.14200 V with 3 decimals of accuracy

[09:58:25][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 0.974A after 743 different samples (1238 SPS)

[09:58:26][D][sensor:094]: 'Measured Current': Sending state 0.97399 A with 2 decimals of accuracy

[09:58:30][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 2.60700 V with 3 decimals of accuracy

[09:58:31][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 0.976A after 740 different samples (1233 SPS)

[09:58:32][D][sensor:094]: 'Measured Current': Sending state 0.97579 A with 2 decimals of accuracy

[09:58:36][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 2.69700 V with 3 decimals of accuracy

[09:58:38][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 0.978A after 749 different samples (1248 SPS)

[09:58:38][D][sensor:094]: 'Measured Current': Sending state 0.97809 A with 2 decimals of accuracy

[09:58:42][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 3.15500 V with 3 decimals of accuracy

[09:58:43][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 1.042A after 463 different samples (771 SPS)

[09:58:44][D][sensor:094]: 'Measured Current': Sending state 1.04248 A with 2 decimals of accuracy

[09:58:48][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 1.43600 V with 3 decimals of accuracy

[09:58:50][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 0.988A after 688 different samples (1146 SPS)

[09:58:50][D][sensor:094]: 'Measured Current': Sending state 0.98785 A with 2 decimals of accuracy

[09:58:54][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 3.15500 V with 3 decimals of accuracy

[09:58:55][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 1.066A after 492 different samples (820 SPS)

[09:58:56][D][sensor:094]: 'Measured Current': Sending state 1.06568 A with 2 decimals of accuracy

[09:59:00][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 0.14200 V with 3 decimals of accuracy

[09:59:02][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 1.090A after 509 different samples (848 SPS)

[09:59:02][D][sensor:094]: 'Measured Current': Sending state 1.09028 A with 2 decimals of accuracy

[09:59:06][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 3.15500 V with 3 decimals of accuracy

[09:59:08][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 1.073A after 498 different samples (830 SPS)

[09:59:08][D][sensor:094]: 'Measured Current': Sending state 1.07275 A with 2 decimals of accuracy

[09:59:12][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 3.15500 V with 3 decimals of accuracy

[09:59:13][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 1.070A after 487 different samples (811 SPS)

[09:59:14][D][sensor:094]: 'Measured Current': Sending state 1.06961 A with 2 decimals of accuracy

[09:59:18][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 0.14200 V with 3 decimals of accuracy

[09:59:20][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 1.082A after 502 different samples (836 SPS)

[09:59:20][D][sensor:094]: 'Measured Current': Sending state 1.08153 A with 2 decimals of accuracy

[09:59:24][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 0.14200 V with 3 decimals of accuracy

[09:59:26][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 1.067A after 482 different samples (803 SPS)

[09:59:26][D][sensor:094]: 'Measured Current': Sending state 1.06698 A with 2 decimals of accuracy

[09:59:30][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 0.14200 V with 3 decimals of accuracy

[09:59:32][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 1.087A after 504 different samples (840 SPS)

[09:59:32][D][sensor:094]: 'Measured Current': Sending state 1.08694 A with 2 decimals of accuracy

[09:59:36][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 0.14200 V with 3 decimals of accuracy

[09:59:38][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 1.079A after 496 different samples (826 SPS)

[09:59:38][D][sensor:094]: 'Measured Current': Sending state 1.07930 A with 2 decimals of accuracy

[09:59:42][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 0.55400 V with 3 decimals of accuracy

[09:59:44][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 1.073A after 491 different samples (818 SPS)

[09:59:44][D][sensor:094]: 'Measured Current': Sending state 1.07325 A with 2 decimals of accuracy

[09:59:48][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 3.08800 V with 3 decimals of accuracy

[09:59:49][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 1.073A after 496 different samples (826 SPS)

[09:59:50][D][sensor:094]: 'Measured Current': Sending state 1.07312 A with 2 decimals of accuracy

[09:59:54][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 3.15500 V with 3 decimals of accuracy

[09:59:56][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 1.081A after 501 different samples (835 SPS)

[09:59:56][D][sensor:094]: 'Measured Current': Sending state 1.08149 A with 2 decimals of accuracy

[10:00:00][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 3.12200 V with 3 decimals of accuracy

[10:00:01][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 1.069A after 492 different samples (820 SPS)

[10:00:02][D][sensor:094]: 'Measured Current': Sending state 1.06862 A with 2 decimals of accuracy

[10:00:06][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 3.15500 V with 3 decimals of accuracy

[10:00:07][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 1.071A after 492 different samples (820 SPS)

[10:00:08][D][sensor:094]: 'Measured Current': Sending state 1.07108 A with 2 decimals of accuracy

[10:00:12][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 1.35700 V with 3 decimals of accuracy

[10:00:14][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 1.066A after 486 different samples (810 SPS)

[10:00:14][D][sensor:094]: 'Measured Current': Sending state 1.06593 A with 2 decimals of accuracy

[10:00:18][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 1.47000 V with 3 decimals of accuracy

[10:00:20][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 1.074A after 498 different samples (830 SPS)

[10:00:20][D][sensor:094]: 'Measured Current': Sending state 1.07407 A with 2 decimals of accuracy

[10:00:24][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 3.15500 V with 3 decimals of accuracy

[10:00:26][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 1.068A after 483 different samples (805 SPS)

[10:00:26][D][sensor:094]: 'Measured Current': Sending state 1.06790 A with 2 decimals of accuracy

[10:00:30][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 3.15500 V with 3 decimals of accuracy

[10:00:32][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 1.075A after 485 different samples (808 SPS)

[10:00:32][D][sensor:094]: 'Measured Current': Sending state 1.07491 A with 2 decimals of accuracy

[10:00:36][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 3.15500 V with 3 decimals of accuracy

[10:00:38][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 1.069A after 487 different samples (811 SPS)

[10:00:38][D][sensor:094]: 'Measured Current': Sending state 1.06885 A with 2 decimals of accuracy

[10:00:42][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 2.84200 V with 3 decimals of accuracy

[10:00:44][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 1.076A after 491 different samples (818 SPS)

[10:00:44][D][sensor:094]: 'Measured Current': Sending state 1.07634 A with 2 decimals of accuracy

[10:00:48][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 3.15500 V with 3 decimals of accuracy

[10:00:50][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 1.032A after 700 different samples (1166 SPS)

[10:00:50][D][sensor:094]: 'Measured Current': Sending state 1.03182 A with 2 decimals of accuracy

[10:00:54][D][sensor:094]: 'adc_sensor_wash_machine': Sending state 0.14200 V with 3 decimals of accuracy

[10:00:56][D][ct_clamp:042]: 'Measured Current' - Raw AC Value: 1.044A after 719 different samples (1198 SPS)

[10:00:56][D][sensor:094]: 'Measured Current': Sending state 1.04399 A with 2 decimals of accuracy

this is my config, I have not done any calibration yet because I can not get the sensor to report stable values.


### CT CLAMP ###

sensor:

- platform: adc

pin: GPIO34

id: adc_sensor_wash_machine

attenuation: 12db

accuracy_decimals: 3

# update_interval: never

update_interval: 6s

- platform: ct_clamp

sensor: adc_sensor_wash_machine

name: "Measured Current"

internal: true

id: voltage

sample_duration: 600ms

update_interval: 6s

filters:

clamp:

min_value: 0

max_value: 30

# - calibrate_linear:

# - 0.012 -> 0

# - 0.025 -> 1.0

I have recheck the circuit several times and to me it seems to be correct.

The Arrows on the CT clamp are pointing to the load connection (hair dryer pistol with 1400w for testing). The clamp is rated as 30A/1V.

Any ideas what can be wrong, or what I am doing wrong?

EDIT:

The problem was that I was using TIP(red) and RING(white) cables. I needed to use TIP(red) and SLEEVE(black) cables, like the specs said…

Is it working for you after using the TIP and Sleeve with above mentioned yaml?

Yes. I see now a constant 1.67 on the input pin when no load is given.

I now just need to calibrate it.

Have you got this setup completed? I was trying setup something similar to this one, but I was not getting the constant output from the setup. I have kept that in the “hold” list and continued on other project. If it is working for you then can you share the yaml and schematic diagram please?

The ESP32 ADC is noisy and or maybe it is to do with the software implementation… Anyhow you can get good data with allot of filtering…

In this example I use the same code to measure voltage with a voltage sense transformer:

  - platform: ct_clamp #current sensor component can be used to measure voltage
    sensor: voltage_sensor_pin
    name: "Voltage"
    unit_of_measurement: V
    device_class: voltage
    id: voltage
    sample_duration: 500ms
    update_interval: 2000ms
    accuracy_decimals: 5
    filters: 
      - sliding_window_moving_average: 
          send_every: 5
          window_size: 60
      - calibrate_linear:
          - 0.0035 -> 0
          - 0.246 -> 118.5

  - platform: adc
    pin: 6
    id: voltage_sensor_pin
    accuracy_decimals: 5
    attenuation: 12db #0db
    name: Voltage Sensor ADC
1 Like

Hi,
Would it also be possible to use multiple clamps on one ESP32 (which has more usable adc channels if I am correct) with this schematic? So connecting one lead of multiple clamps to the same 1.65V point, and then every other lead to it’s own adc pin? Or should each clamp get it’s own voltage divider? Or is this not possible at all?

Hey @Martidjen did you have a chance to test it? Just came to the same dilemma and I believe one voltage divider should be enough?

You want multiple voltage dividers. They will interact otherwise.