10 static const char *
const TAG =
"ct_clamp";
13 LOG_SENSOR(
"",
"CT Clamp Sensor",
this);
14 ESP_LOGCONFIG(TAG,
" Sample Duration: %.2fs", this->
sample_duration_ / 1e3f);
15 LOG_UPDATE_INTERVAL(
this);
37 const float rms_ac_squared = rms_ac_dc_squared - rms_dc * rms_dc;
39 if (rms_ac_squared > 0)
40 rms_ac = std::sqrt(rms_ac_squared);
41 ESP_LOGD(TAG,
"'%s' - Raw AC Value: %.3fA after %" PRIu32
" different samples (%" PRIu32
" SPS)",
60 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
Implementation of SPI Controller mode.