ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
ct_clamp_sensor.h
Go to the documentation of this file.
1#pragma once
2
4#include "esphome/core/hal.h"
7
8namespace esphome::ct_clamp {
9
11 public:
12 void update() override;
13 void loop() override;
14 void dump_config() override;
15 float get_setup_priority() const override {
16 // After the base sensor has been initialized
17 return setup_priority::DATA - 1.0f;
18 }
19
20 void set_sample_duration(uint32_t sample_duration) { sample_duration_ = sample_duration; }
22
23 protected:
26
31
45 float last_value_ = 0.0f;
46 float sample_sum_ = 0.0f;
47 float sample_squared_sum_ = 0.0f;
49 bool is_sampling_ = false;
50};
51
52} // namespace esphome::ct_clamp
Helper class to request loop() to be called as fast as possible.
Definition helpers.h:1993
This class simplifies creating components that periodically check a state.
Definition component.h:585
void set_source(voltage_sampler::VoltageSampler *source)
float get_setup_priority() const override
voltage_sampler::VoltageSampler * source_
The sampling source to read values from.
float last_value_
The DC offset of the circuit.
uint32_t sample_duration_
Duration in ms of the sampling phase.
HighFrequencyLoopRequester high_freq_
High Frequency loop() requester used during sampling phase.
void set_sample_duration(uint32_t sample_duration)
Base-class for all sensors.
Definition sensor.h:47
Abstract interface for components to request voltage (usually ADC readings)
constexpr float DATA
For components that import data from directly connected sensors like DHT.
Definition component.h:43
static void uint32_t