9 static const char *
const TAG =
"ct_clamp";
12 LOG_SENSOR(
"",
"CT Clamp Sensor",
this);
13 ESP_LOGCONFIG(TAG,
" Sample Duration: %.2fs", this->
sample_duration_ / 1e3f);
14 LOG_UPDATE_INTERVAL(
this);
36 const float rms_ac_squared = rms_ac_dc_squared - rms_dc * rms_dc;
38 if (rms_ac_squared > 0)
39 rms_ac = std::sqrt(rms_ac_squared);
40 ESP_LOGD(TAG,
"'%s' - Raw AC Value: %.3fA after %d different samples (%d SPS)", this->
name_.
c_str(), rms_ac,
59 if (std::isnan(value))
uint32_t sample_duration_
Duration in ms of the sampling phase.
float sample_squared_sum_
void set_timeout(const std::string &name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
HighFrequencyLoopRequester high_freq_
High Frequency loop() requester used during sampling phase.
voltage_sampler::VoltageSampler * source_
The sampling source to read values from.
void start()
Start running the loop continuously.
virtual float sample()=0
Get a voltage reading, in V.
float last_value_
The DC offset of the circuit.
void publish_state(float state)
Publish a new state to the front-end.
void stop()
Stop running the loop continuously.
constexpr const char * c_str() const
void dump_config() override