Hi all,
I’ve just configured a CT clamp sensor, and confirmed it’s working just fine with some Arduino sketch code, but in ESPHome it’s behaving strangly.
The ct_clamp sensor should be sampling the adc several hundred or thousand times a second, the default sample period is 200ms and most people’s experience is that this gives about 500 samples, which is plenty to calculate the RMS value of the 50hz AC sinewave.
However in my setup, on a Wemos ESP32 the ct_clamp is only taking a single sample… claiming it has a sample rate of 5 samples per second. This will never work for sampling a 50hz signal!
I can’t work out what is going wrong, is there a setting somewhere for the global ADC sample rate?
Config:
sensor:
- platform: adc
pin: GPIO34
id: adc0
- platform: adc
pin: GPIO35
id: adc1
- platform: adc
pin: GPIO36
id: adc2
- platform: adc
pin: GPIO39
id: adc3
- platform: ct_clamp
sensor: adc0
name: "Total Energy Usage"
update_interval: 10s
- platform: ct_clamp
sensor: adc1
name: "House Energy Usage"
update_interval: 10s
- platform: ct_clamp
sensor: adc2
name: "Garage Energy Usage"
update_interval: 10s
- platform: ct_clamp
sensor: adc3
name: "EV Charger Energy Usage"
update_interval: 10s
Output:
[08:34:28][D][ct_clamp:041]: 'EV Charger Energy Usage' - Raw AC Value: 0.000A after 1 different samples (5 SPS)
[08:34:28][D][sensor:094]: 'EV Charger Energy Usage': Sending state 0.00000 A with 2 decimals of accuracy
[08:34:28][D][ct_clamp:041]: 'House Energy Usage' - Raw AC Value: 0.000A after 1 different samples (5 SPS)
[08:34:28][D][sensor:094]: 'House Energy Usage': Sending state 0.00000 A with 2 decimals of accuracy
[08:34:28][D][ct_clamp:041]: 'Total Energy Usage' - Raw AC Value: 0.000A after 1 different samples (5 SPS)
[08:34:28][D][sensor:094]: 'Total Energy Usage': Sending state 0.00000 A with 2 decimals of accuracy
[08:34:31][D][ct_clamp:041]: 'Garage Energy Usage' - Raw AC Value: 0.000A after 1 different samples (5 SPS)
[08:34:31][D][sensor:094]: 'Garage Energy Usage': Sending state 0.00000 A with 2 decimals of accuracy
[08:34:36][D][sensor:094]: 'adc2': Sending state 1.03300 V with 2 decimals of accuracy
[08:34:38][D][ct_clamp:041]: 'EV Charger Energy Usage' - Raw AC Value: 0.000A after 1 different samples (5 SPS)
[08:34:38][D][sensor:094]: 'EV Charger Energy Usage': Sending state 0.00000 A with 2 decimals of accuracy
[08:34:38][D][ct_clamp:041]: 'House Energy Usage' - Raw AC Value: 0.000A after 1 different samples (5 SPS)
[08:34:38][D][sensor:094]: 'House Energy Usage': Sending state 0.00000 A with 2 decimals of accuracy
[08:34:38][D][ct_clamp:041]: 'Total Energy Usage' - Raw AC Value: 0.000A after 1 different samples (5 SPS)
[08:34:38][D][sensor:094]: 'Total Energy Usage': Sending state 0.00000 A with 2 decimals of accuracy