ESPHome  2024.10.2
adc128s102_sensor.cpp
Go to the documentation of this file.
1 #include "adc128s102_sensor.h"
2 
3 #include "esphome/core/log.h"
4 
5 namespace esphome {
6 namespace adc128s102 {
7 
8 static const char *const TAG = "adc128s102.sensor";
9 
10 ADC128S102Sensor::ADC128S102Sensor(uint8_t channel) : channel_(channel) {}
11 
13 
15  LOG_SENSOR("", "ADC128S102 Sensor", this);
16  ESP_LOGCONFIG(TAG, " Pin: %u", this->channel_);
17  LOG_UPDATE_INTERVAL(this);
18 }
19 
20 float ADC128S102Sensor::sample() { return this->parent_->read_data(this->channel_); }
21 void ADC128S102Sensor::update() { this->publish_state(this->sample()); }
22 
23 } // namespace adc128s102
24 } // namespace esphome
const float DATA
For components that import data from directly connected sensors like DHT.
Definition: component.cpp:19
void publish_state(float state)
Publish a new state to the front-end.
Definition: sensor.cpp:39
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7