ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
ads1115_sensor.cpp
Go to the documentation of this file.
1#include "ads1115_sensor.h"
2
3#include "esphome/core/log.h"
4
5namespace esphome::ads1115 {
6
7static const char *const TAG = "ads1115.sensor";
8
10 return this->parent_->request_measurement(this->multiplexer_, this->gain_, this->resolution_, this->samplerate_);
11}
12
14 float v = this->sample();
15 if (!std::isnan(v)) {
16 ESP_LOGD(TAG, "'%s': Got Voltage=%fV", this->get_name().c_str(), v);
17 this->publish_state(v);
18 }
19}
20
22 LOG_SENSOR(" ", "ADS1115 Sensor", this);
23 ESP_LOGCONFIG(TAG,
24 " Multiplexer: %u\n"
25 " Gain: %u\n"
26 " Resolution: %u\n"
27 " Sample rate: %u",
28 this->multiplexer_, this->gain_, this->resolution_, this->samplerate_);
29}
30
31} // namespace esphome::ads1115
const StringRef & get_name() const
Definition entity_base.h:71
void publish_state(float state)
Publish a new state to the front-end.
Definition sensor.cpp:68