I am trying to set up a ct_clamp for current reading. I am using a 100A/50mA clamp with a Mottramlabs current load resistor of 22ohms (10k dividers and capacitor to give 1.65v mid point). With no current flowing I get a varying reading of between about 0.07 and 0.12, with the current clamp unplugged, so just across the load resistor I still get readings from 0.005 to 0.012. I have tried 2 different SDC ports.
The jumper cables from ESP32 dev board to the mottramlabs board are only about 10cm long, so shouldn’t be picking up too much stray EMI.
Is 5s too short a time and I need to sample over a longer period to average this out and set a linear filter to adjust the 0 point?
[11:12:35][D][api.connection:918]: Home Assistant 2023.1.4 (::FFFF:192.168.1.11): Connected successfully
[11:12:38][D][ct_clamp:038]: 'Measured Current' - Raw AC Value: 0.016A after 459 different samples (2295 SPS)
[11:12:38][D][sensor:127]: 'Measured Current': Sending state 0.01554 A with 2 decimals of accuracy
[11:12:43][D][ct_clamp:038]: 'Measured Current' - Raw AC Value: 0.006A after 473 different samples (2365 SPS)
[11:12:43][D][sensor:127]: 'Measured Current': Sending state 0.00618 A with 2 decimals of accuracy
[11:12:48][D][ct_clamp:038]: 'Measured Current' - Raw AC Value: 0.007A after 466 different samples (2330 SPS)
[11:12:48][D][sensor:127]: 'Measured Current': Sending state 0.00737 A with 2 decimals of accuracy
[11:12:53][D][ct_clamp:038]: 'Measured Current' - Raw AC Value: 0.021A after 447 different samples (2235 SPS)
[11:12:53][D][sensor:127]: 'Measured Current': Sending state 0.02102 A with 2 decimals of accuracy
[11:12:58][D][sensor:127]: 'adc_sensor': Sending state 1.69500 V with 2 decimals of accuracy
[11:12:58][D][ct_clamp:038]: 'Measured Current' - Raw AC Value: 0.019A after 421 different samples (2105 SPS)
[11:12:58][D][sensor:127]: 'Measured Current': Sending state 0.01895 A with 2 decimals of accuracy
[11:13:03][D][ct_clamp:038]: 'Measured Current' - Raw AC Value: 0.016A after 460 different samples (2300 SPS)
[11:13:03][D][sensor:127]: 'Measured Current': Sending state 0.01569 A with 2 decimals of accuracy
[11:13:08][D][ct_clamp:038]: 'Measured Current' - Raw AC Value: 0.005A after 457 different samples (2285 SPS)
[11:13:08][D][sensor:127]: 'Measured Current': Sending state 0.00523 A with 2 decimals of accuracy
[11:13:13][D][ct_clamp:038]: 'Measured Current' - Raw AC Value: 0.015A after 460 different samples (2300 SPS)
[11:13:13][D][sensor:127]: 'Measured Current': Sending state 0.01466 A with 2 decimals of accuracy
So you’re in mA mode given that you said that you have a 22R resistor in the circuit? What burden resistance does the CT have?
Surely no current across the CT should yield a stable current at the ADC port, so I’d focus on that initially. Use a DVM to measure the current off the CT and also measure the VOLTAGE at A0(ADC) with the NodeMCU out of the circuit. No point in setting the calibration/linear until that’s stable at 0A.
Also try simplify the YAML by going back to the defaults of 60sec for the interval and taking out the attenuation unless it’s specifically specified for the Mains Power Sensor?
(CT clamp resistance to answer your question is about 180Ω) it’s marked as 100A/50mA so no measurement resistor in the clamp unit.
No current across the CT should yield a stable [voltage] at the ADC port - yes, that should be the case but the voltage the ADC measures fluctuates even with the CT clamp removed, hence the question.
The interval is the reporting interval to ESPHome - the measurement interval is the default of 200mS - the way the analogue monitor works is to take multiple samples then use the highest and lowest (the ADC is getting a sine wave so needs to monitor several phases of the voltage - 200mS gives 10 cycles at 50Hz.
removing the attenuation causes nan error - was tempted to report this as a bug as it should still be OK at 0db?
Again, I’d put a DVM on A0 and see what you have with 0A on the CT. Also check that you have a stable 3.3v - may be you’re stretching the current from the onboard supply and it’s bringing the +V down and causing sampling issues.
I am using the same setup as you however I get zero readings. I wondered if you would be interested in sharing code, board setups and ESP32 information to help each other.