ESPHome  2024.12.2
adc_sensor_common.cpp
Go to the documentation of this file.
1 #include "adc_sensor.h"
2 #include "esphome/core/log.h"
3 
4 namespace esphome {
5 namespace adc {
6 
7 static const char *const TAG = "adc.common";
8 
10  float value_v = this->sample();
11  ESP_LOGV(TAG, "'%s': Got voltage=%.4fV", this->get_name().c_str(), value_v);
12  this->publish_state(value_v);
13 }
14 
15 void ADCSensor::set_sample_count(uint8_t sample_count) {
16  if (sample_count != 0) {
17  this->sample_count_ = sample_count;
18  }
19 }
20 
22 
23 } // namespace adc
24 } // namespace esphome
const float DATA
For components that import data from directly connected sensors like DHT.
Definition: component.cpp:19
void set_sample_count(uint8_t sample_count)
void publish_state(float state)
Publish a new state to the front-end.
Definition: sensor.cpp:39
void update() override
Update ADC values.
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
float get_setup_priority() const override
HARDWARE_LATE setup priority
const StringRef & get_name() const
Definition: entity_base.cpp:10