ESPHome 2025.5.0
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 {
9namespace ct_clamp {
10
12 public:
13 void update() override;
14 void loop() override;
15 void dump_config() override;
16 float get_setup_priority() const override {
17 // After the base sensor has been initialized
18 return setup_priority::DATA - 1.0f;
19 }
20
21 void set_sample_duration(uint32_t sample_duration) { sample_duration_ = sample_duration; }
23
24 protected:
27
32
46 float last_value_ = 0.0f;
47 float sample_sum_ = 0.0f;
48 float sample_squared_sum_ = 0.0f;
49 uint32_t num_samples_ = 0;
50 bool is_sampling_ = false;
51};
52
53} // namespace ct_clamp
54} // namespace esphome
Helper class to request loop() to be called as fast as possible.
Definition helpers.h:630
This class simplifies creating components that periodically check a state.
Definition component.h:301
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:57
Abstract interface for components to request voltage (usually ADC readings)
const float DATA
For components that import data from directly connected sensors like DHT.
Definition component.cpp:19
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7