I want to make a custom ct sensor. Specifically I would like to try to add arc detection sensing into the component by looking for high frequencies, i.e. large changes within the cycle, basically recording peak difference between samples. My intuition tells me it may work and I would like to try.
I looked at the ct component source code but I cant figure out where the measurements are done, it sais it is being done in the loop, but where is the code for it?
esphome/esphome/components/ct_clamp/ct_clamp_sensor.cpp at dd18a219db7e4d7306c4cbd088baecfd146a811d · esphome/esphome · GitHub or esphome/esphome/components/ct_clamp/ct_clamp_sensor.h at dd18a219db7e4d7306c4cbd088baecfd146a811d · esphome/esphome · GitHub
Not an expert on arcs, but pretty sure they are high frequency. Most CTs have very poor high frequency response. You also need to sample at least twice as fast as the highest frequency you need to “see” (Shannon/Nyquist theories/laws). The loop in a esp32 might be as quick as 1ms, but is likely much slower. You would need a high speed ADC, possibly doing DNA and the post process the data. Even an esp32 probably isn’t capable enough and this is not in the realm of something I would suggest for esphome, definitely not going to be easy.
But, the code you seek is in the loop function (which you can see gets one sample from the ADC for each run of the loop).
Thanks, I looked at that but cant figure out how the actual ADC reading is made. I may need to make a a lambda to make it quick enough.
Thanks,
I am very familiar with electronics and also arc. Yes, you generally do it by detecting high frequencies, but I do think it is possible by just analyzing the samples and a little bit of intelligence.
ESP32 sampling time is theoretically under 1us, but code will be a limiting factor.
Looks like I cant do it as a component in ESPHome, but may be possible within a lambda function.
Will do a bit of testing and report back.
Since you are familiar with electronics, what sample rate do you need?
You might be able to do something with the way microphone data is handled, that gets you to at least audio frequency.
You are likely to get some traction on the esphome discord channel, developers hang out there.