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.
@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
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.
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.
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.
Thanks for the explanation. I’ll have to research some more as I have pretty tenuous grasp.
Have a look at these plots:
The first blue plot is similar to what comes out of the CT. A sine wave centred on 0V swinging both positive and negative.
The ADC can only measure from 0 to 3.3V (middle red plot).
By shifting the CT output up a constant DC amount (1V in the third magenta graph) The ADC can now measure the full waveform as it is all above 0V.
The position of this DC bias point should be half way between 3.3V and 0 to meaure the maximum possible positive and negative parts of the CT waveform.
Supplying the voltage divider with 5V would shift this bias point too high (2.5V instead of 1.65V).
Thanks @tom_l . Very clear explanation. The CT sensor I am using is from the Emporia Vue2 kit and I’m pretty sure it has something built into it. Only outputs 0-0.333v for the 50A clamp.
How are you measuring the 0 a 3.333v? You should be using a voltmeter set on AC voltage measurement. A Current Transformer monitoring an AC device generates an AC current or voltage, depending on the specific type of device. A normal AC voltmeter will not show any negative values. You need an oscilloscope to show the waveforms above.