ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
resistance_sensor.h
Go to the documentation of this file.
1#pragma once
2
5
6namespace esphome::resistance {
7
12
13class ResistanceSensor final : public Component, public sensor::Sensor {
14 SUB_SENSOR(source)
15
16 public:
17 void set_configuration(ResistanceConfiguration configuration) { configuration_ = configuration; }
18 void set_resistor(float resistor) { resistor_ = resistor; }
19 void set_reference_voltage(float reference_voltage) { reference_voltage_ = reference_voltage; }
20
21 void setup() override {
22 this->source_sensor_->add_on_state_callback([this](float value) { this->process_(value); });
23 if (this->source_sensor_->has_state())
24 this->process_(this->source_sensor_->state);
25 }
26 void dump_config() override;
27
28 protected:
29 void process_(float value);
31 float resistor_;
33};
34
35} // namespace esphome::resistance
Base-class for all sensors.
Definition sensor.h:48
void add_on_state_callback(F &&callback)
Add a callback that will be called every time a filtered value arrives.
Definition sensor.h:122
uint32_t value
Definition hal.cpp:41