CT Current sensor wiring?

I purchased this Non-Invasive Current Sensor - 30A:

I am making this energy tracker with esp32:

Diagram:

The CT current sensor has three positions on the 3.5mm plug. Which ones should I be using? I clamped it around a wire feeding a 2.2kW kettle, and it measured 23 volts on the tip and 2.1 volts on the middle connection.

Appreciate your help.

1 Like

Hi David,

I’d check out the Sparkfun tutorial here: Environmental Monitoring with the Tessel 2 - SparkFun Learn

Unfortunately the datasheet doesn’t include the TRS jack.

2 Likes

Thanks Liam, I think that has helped me to understand it. They have gone tip ans sleeve, ignoring the middle ring. I have changed my breadboard to match the way they hooked it up. I just need to hook the tip and sleeve up to this where my orange wires are.

<image removed as it was wired incorrectly, and I do not want to lead to anyone copying it.>

3 Likes

Hi David

You don’t say if you measured WRT ground, or is this voltage DC or AC and is it P-P or what you measured with.

23V is way too high. you might have fried something. You should measure WRT ground 1.65V at the resistor junction (half 3.3V) and at the analog input an AC voltage with a 1.65V DC offset. You will need an oscilloscope to do this.

Please check your wiring.
Everything is wrong.
If the orange wires go to the sensor you have 10kΩ across the sensor as a burden resistor instead of 22Ω ad a low value across the cap. Difficult to make out exactly what the value is but looks like 20Ω. There is a 10k resistor going diagonally across to the top orange wire. You need to connect this across the cap and put the low value resistor in its place. In other words you seem to have the 2 resistors swapped.
Also the lower orange wire should go to the junction of the resistors and the cap positive. It is currently going to ground. That is if you are wiring to the circuit above.

If you have applied anything like 23V to that board I would suspect damage.
Cheers Bob
But you haven’t said how you measured this 23V so I suppose it could be anything.

2 Likes

My first test was just to put the clamp around live cable going to a kettle, turn on kettle and measure the tip to sleeve voltage with a multimeter on AC setting. I don’t know if this is a valid test?

I have not yet hooked the ct clamp to my circuit. I hear what you say about my resistors, and i will check them tomorrow, possibly i put them in wrong. There is meant to be a burden resistor across the capacitor that i am using 20 ohm for right now. The other two are 100 kohm.

I want to try to connect the ct clamp to the circuit tomorrow (without esp32 connected), and measure the voltage from the line i am sending in to the esp32 for measurement, to ground. I need to make sure it is somewhere around 2 volt or under. Bit of a learning project for me.

If i remove the esp32 and hook the ct clamp to the circuit, can i measure the voltage that till be sent to the esp32 as above?

Thanks for your help.

1 Like

The burden resistor is supposed to be across the sensor output (coil) NOT the capacitor. The circuit is correct, your wiring is wrong.

The 4th ring in the pics looks red, I suppose it could be orange but it looks the same as the red band on the 20Ω resistor.
The last time I looked brown black black red was 10kΩ. Brown black black orange is 100k.
10k or 100k in that circuit is not going to make a lot of difference as long as they are both the same. These resistors are only providing a voltage (half Vcc) to level shift the AC from the coil and make it look like a varying DC voltage when applied to the analog input.

Swapping the 20Ω for a 10k (or 100k) for the burden resistor WILL make a very large difference. This is where the 23V comes from. This should be something less than 1VAC measured straight across the sensor output (with the 20Ω burden resistor in the correct place.
What you measure here with a DMM (AC) will be RMS. Multiply this by 2.83 to get peak to peak value which is what the analog input will see.
With this circuit the analog voltage WRT ground (which the analog input will actually see) will be this P-P Ac voltage shifted by the voltage at the junction of the 2 high value resistors (half Vcc or in this case 1.65V)
Ideally this should be viewed with an oscilloscope but if you don’t have one you will have to take my word for it.
Cheers Bob

1 Like

Ahh, yes, I see I did put the wrong resistor placement. This was the diagram i was following,

https://learn.sparkfun.com/tutorials/environmental-monitoring-with-the-tessel-2

But yes, i put the burden resistor in the wrong place. I appreciate your help with this. Nothing has had any power go through it from esp32 or the ct clamp, so caught it in time.

Appologies, yes I went with 10 k resistors. Some people used 10k, others used 100k resistors. Is there an actual benefit of 10k or 100k? I have 100k spare, so can easily do that instead.

I am pretty sure i have a 10 ohm resistor in my pack. Will this be a better option for the burden resistor? I read that this has an impact on the final voltage to the esp32 for measurement. I will be measuring a 4000 watt water heater

Will revisit this tomorrow, fix the mistakes and upload a new pic before i hook any power to it.

Thanks for your time and expertise. My expertise is on the software side. Circuitry is something i am trying to learn and understand.

1 Like

Hi David

Not really for this application. Most (myself included) would use 10k as the current draw from the 3.3V supply is only 0.33mA and the 100k just makes the current 0.033mA.
I personally don’t like high values in what is basically a low voltage situation so would prefer the 10k here.

That is correct. The sensor produces a current in proportion to the AC current through the device. It is actually a transformer with a single turn primary (the wire that goes through it). This current then passes through the burden resistor thus producing a voltage drop across it. This voltage is then used by any voltage operated system that is connected. I would leave it at 20Ω for a test and see what you get.

Be a bit careful here. Some sensors will have a burden resistor built in. These will be designated as a “voltage” output as against sensors without a built in resistor which will be designated as “current” output.

Exactly which sensor are you using.
Just looked and if you are using the one you linked the data sheet indicates a current output as the burden resistor is marked as externally required.
The output is quoted as 15mA @ 30A primary which is graphed as 150mV which is correct as per graph for 10Ω burden.
I am assuming this is all RMS voltage and current. This needs confirmation. If this is the case you will be interested in peak values. 150mV RMS is +/- 212mV peak (or 424mV Peak to peak). That offset in that circuit is 1.65V. This means the voltage at the output (WRT Ground) would be 1.65 plus the +/- 2.12mV which results in a varying DC voltage between 1.438V to 1.862V. I remind you that this is for 30A primary and 10Ω burden.
If you can understand all that you will see that the output voltage can be scaled by changing the value of the burden resistor so by increasing to 20Ω you will get an output of 300mV for a 30A primary so all the other numbers (except the 1.65V offset) can be scaled up accordingly.

Warning DO NOT OPERATE WITHOUT THE BURDEN RESISTOR. Doing so could reflect an open circuit back into the single turn primary winding at the measuring point with all sorts of possible scenarios.
Cheers Bob
Add on
Of course another way of looking at this. If the primary is measured as RMS the sensor output will be RMS and so on. If this is applied to an analog input then it will be the Peak value which will be of interest.

FYI the offset (1.65V) is required as a negative voltage should not be applied to an analog input only designed for positive. Such as single supply operation. The input circuitry will be damaged by any negative (WRT negative supply or Ground) voltage.

1 Like

Thank you for that reply Bob. I will have to read that a few times to grasp the information.

I redid the wiring and I think this is now correct thanks to your help. Note, I swapped out the 20 ohm burden resistor for a 100 ohm burden resistor. I can return to the 20 easily. Would the 100 ohm be overall safer?

My primary objective is to first detect that any current is flowing to the 240v, 3.6 kW (15 amp) water heater without breaking the sensor or the esp32 with a mistake. From there I can play with the values to get accurate readings of the current draw as I understand it a little more.

1 Like

Hi David
Hold everything!!!

No it would not. Go back to the 20Ω and start from there.
You are thinking backwards. The 100Ω resistor will result in an INCREASE in output voltage and at 5 times the 20Ω or 10 times the 10Ω figure there is a possibility you could exceed the allowable analog input.

The old saying. crawl before you walk I think applies here.
Cheers Bob

1 Like

Ok understood. I might swap in a 10 ohm then just to be safe. Super busy at work, so am just doing this in my spare time which is not a lot right now.

Probably be Thursday before i get a chance ro plug it in and test if for real.

I appreciate your help.

1 Like

Hi David

Good idea. You can work on it from there. You might even finish up with close to 100Ω but starting low and adjusting is better than beginning at the top and frying your analog input beyond use.

You do realise that you are going to finish up with a 50Hz sine wave AC voltage level shifted by half Vcc (1.65V) don’t you. This moves the sine wave 1.6V in a positive direction to prevent any negative voltage being presented to the analog input (which is a no no) which would damage the input. Thus it will be a positive voltage varying in a sine wave fashion. What you are going to do with this is up to you .

If you measure the resultant voltage WRT Ground which the analog input will see you will measure 1.65V as the DMM on DC ranges will read the average of the sine wave which will be the 1.65V offset.
The meter on ACV range will measure the AC component as RMS. The analog input will of course see a peak voltage. This will be the RMS value multiplied by 1.414. Thus the voltage swing the analog input will actually see will be the offset voltage plus and minus this peak value.
If you have an oscilloscope you could see a pictorial view of what is happening. If I get a bit of time later I might be able to simulate this and show you.
Cheers Bob

1 Like

Hi David
A couple of pics for you


This is a 1V peak AC sine wave.

I chose 1V for illustration purposes to show you what should happen. The yellow marker on the left and the grid line across the middle is ground reference.


This is the same sine wave with a 1.65V offset. You can see now that everything is positive WRT Ground. This is what your analog input should see. Note the max and min voltages. 1.65V plus and minus the sine peak voltage. The yellow marker and grid line are still Ground reference.

I hope this goes some way in explaining the reason for the offset… What was originally Ground has been moved 1.65V positive.

Pics taken with the aid of a function generator and oscilloscope.
Cheers Bob

2 Likes

Thank you for that explanation.

I have hooked it up, loaded the code on to the ESP32 from ESPHome, put the clamp around the active lead to a kettle, and it is sending the current usage to Home Assistant successfully. As it stands, the measured current is about 4x smaller than reality. It should be reading about 2200 Watts, but it is reading about 500 Watts. I can now play around to get a more accurate measurement. Within 10% will be fine for my purposes, and anything better than that is a bonus.

I chose the 10 ohm burden resistor. I believe I can fix the reading in the code that I load into the ESP32 device, so I will attempt that first.

Thank you for the oscilloscope readout. Unfortunately I do not own an oscilloscope, only a multi-meter and this esp32 that it is now connected to. I believe that the current configuration is perfectly within the safe voltage range for the esp32 input. I am unsure if I can measure that for fact with my multi-meter?

Thank you Bob for your help on this.

1 Like

Hi David

If you are using the circuit with the half Vcc (1.65V) offset (you have not confirmed this. Please do so and you will save a lot of guess work) you will measure 1.65V DC as this is what the AVERAGE DC voltage is. To establish what the actual peak likely is, measure the voltage as RMS in AC mode. Multiply this by 1.414 and add the offset. This should be what the ADC input sees as maximum.
An oscilloscope would be very useful to confirm this but as you have not got one (and probably have not got the knowledge to use it properly) the above should be a pretty accurate way around this.
Some DMMs (mine included) have a “DC + AC” mode but you still have to know the value of the AC component to establish the peak value. This peak is what the DC input sees and is most important.

Are you sure of this. You should be able to calculate it.
Measure the AC (RMS) voltage across the 10Ω resistor.
Calculate the current through the resistor. AC Voltage (mV) / 10 = Current (mA)
The sensor you linked is quoted as being 15mA per 1A primary current. So…
Current through 10Ω (above calculation) divided by 15 should equal primary AC current in Amps.
This current * 240 =Watts.

Not too complicated really.
Cheers Bob

Note this 15mA per primary Ampere remains constant no matter what value the burden resistor. Changing the burden will change the value of the RMS output volts across re burden. Thus you can arrange this burden value to suit your application.

1 Like

Hi David
This voltage if applied directly to an analog input would be a DC varying up and down in a sine wave fashion. (image of the mains current).
Interested in just what you do with this. If applied to an ADC and recovering the ADC value it would be gyrating all over the place depending at exactly time the sample was taken and would probably mean nothing. In fact it would return a reading of half scale with no AC input at all.
Just a bit curious.
Cheers Bob

2 Likes

The ESP32 is joined to my ESPHome instance, which is running inside Home Assistant. Then, i use YAML to define the desired outcome (imperative). I then install that to the ESP32. The result is that ESPHome compiles the code to achieve the desired outcome. There is a sample_duration, and this is likely what you are discussing. If I set the sample_duration too low (under 300ms, then, yes, the result jumps around a lot. But set the sample duration to 3 seconds, with a reading every 5 seconds, and it is very smooth and accurate now that I set the calibration. Ideally, I would test a few more loads and fill them in to get a more accurate reading over the entire 15 amps. I have only tested it with 8.8 amp load at this time.

sensor:
  - platform: ct_clamp
    sensor: adc_sensor
    name: "${device_name}_hws_raw"
    update_interval: "${update_interval}"
    accuracy_decimals: 5
    
  - platform: ct_clamp
    sensor: adc_sensor
    sample_duration: "${sample_duration}"
    name: "${device_name}_hws_amps_usage"
    update_interval: "${update_interval}"
    accuracy_decimals: 3
    filters:
      - calibrate_linear:
          - 0.000 -> 0
          - 0.084 -> 8.8    # value as per power plug
    unit_of_measurement: "A"

  - platform: ct_clamp
    sensor: adc_sensor
    sample_duration: "${sample_duration}"
    name: "${device_name}_hws_watts_usage"
    id: esp_watts
    update_interval: "${update_interval}"
    accuracy_decimals: 3
    filters:
      - calibrate_linear:
          - 0.000 -> 0
          - 0.084 -> 8.8    # value as per power plug
      - lambda: return x * 240.0;
    unit_of_measurement: "W" 

  - platform: adc
    pin: GPIO34
    id: adc_sensor
    attenuation: 11db
    update_interval: "${update_interval}"

Hi David
Firstly “YAML” is Swahili to me.
I don’t profess to know anything about your sketch or the language used but I don’t see anything that looks like peak to RMS conversions or any allowance for the introduced 1.65V offset.
You are using that circuit published earlier or aren’t you. You haven’t answered that question yet.
I am a bit confused but that is not unusual at my stage in life. It is just that the DC (or analog input) should see the AC volts peak value plus the 1.65V offset and you seem to finish up with an RMS result with no conversions that I can see. The “return x * 240.0” to obtain Watts I do understand although where the “return x” comes from I don’t know.

How are you calibrating? I assuming measuring the 240VAC current with another measuring device.

If so are you then scaling something to get the same value with your set up. This will be OK for that value but if you have the 1.65V offset that will be constant and it the sine wave component that will change so if the 240VAC current halves the peak voltage at the analog input will not halve in proportion due to the constant 1.65VDC offset.

But if it works at 8.8A and is still accurate at say 4A or 15A then who am I to comment. I will be completely wrong and I will apologise for any confusion I may have caused.

Please keep us posted. Interesting
Cheers Bob

1 Like

Hi David
I must be losing the plot. Please accept my apologies for confusing the issue.
I think your bit “calibrate linear” will remove the static offset voltages whatever the ADC reads with no primary current will be remapped to “0” and a current of 8.8A will be mapped to 8.8 so after a fair bit of rethinking you might be OK with what you have done. Even though I don’t understand that sketch but that is immaterial.

I think I was confusing myself as being a basically analog person I would have tackled this problem a bit differently. I would have not used any offset and processed the AC component to finish up with a steady DC which represented the peak AC value and measured that. To me that would have been the simplest way. But I stress that is only me. You may have found it easier your way so all good.
Cheers and keep us posted Bob

1 Like

Absolutely no appology needed Bob. I appreciate your help, as I really have only the bare basics in the electronics side. I can follow a Silicon Chip howto, but the what is happening part, that goes over my head.

When it comes to the software, that is my specialty. I can describe whay is happening on the software side a little more later. In this case, the code is not written by me, so i am making some guesses on what is going on under the hood.

When it comes to this style of CT clamp meter hooked up to an analog to digital input on an esp32 or similar, I believe they are taking measurements at a rapid interval in that code (the chip is 240 mHz dual core), and using calculations to convert the sine wave into an amp reading, but i would need to look at the code. With testing, i noticed that 300ms sample_duration provided fairly erratic results. But using 3 seconds smoothed that out a lot. I do not need to be millisecond accurate. A 5 second average is fine.

The raw reading is what is measured by the adc, fed by that wiring i did. I switched out the 10 ohm burden resistor and put in a 20 ohm, closer to the 22 ohm of the initial project i was following. That doubled the raw value, bringing it to that 0.84 for an 8.8 amp load.

In my filters, i only put one value. I plugged in a kettle, measured 8.8 amp with a somewhat trustable power meter, then saw the raw value of 0.084 from tge esp32 code. My line of YAML there states that 0.084 raw is equal to 8.8 amp real. That is one measurement only. I can plug in a lot more loads with different amps required, and can enter as many as i like and plot those too. These will give the code a multi point conversion graph, making the reading really quite accurate. Well, pretty much as accurate as the other power meter anyway.

I have a Uni-T UT210-E clamp meter, so i will double check the measurements with that tomorrow.

In my first picture upload of my breadboard to this forum, I made two mistakes in my wiring. You helped me in discovering them, and I appreciate your help.

When it comes to calculating the watts, i am using the amps x 240. Not completely accurate, but good enough. The x in “return x * 240” refers to the raw value in the adc_sensor after the filters: calibrate_linear has been applied.

I believe i saw a different wiring option somewhere that used the same ct clamp, with different electrical components, fed into another adc on the same esp32, and it measured the volts fairly accurately, giving actual volts and actual amps. I may try to find that one later and attempt that. While i am happy for now to get a warning that the heater is on or off, later on, it woukd be nice to get a fairly accurate watts measurement.

Cheers
David.