ESPHome  2024.11.1
ads1115_sensor.cpp
Go to the documentation of this file.
1 #include "ads1115_sensor.h"
2 
3 #include "esphome/core/log.h"
4 
5 namespace esphome {
6 namespace ads1115 {
7 
8 static const char *const TAG = "ads1115.sensor";
9 
11  return this->parent_->request_measurement(this->multiplexer_, this->gain_, this->resolution_);
12 }
13 
15  float v = this->sample();
16  if (!std::isnan(v)) {
17  ESP_LOGD(TAG, "'%s': Got Voltage=%fV", this->get_name().c_str(), v);
18  this->publish_state(v);
19  }
20 }
21 
23  LOG_SENSOR(" ", "ADS1115 Sensor", this);
24  ESP_LOGCONFIG(TAG, " Multiplexer: %u", this->multiplexer_);
25  ESP_LOGCONFIG(TAG, " Gain: %u", this->gain_);
26  ESP_LOGCONFIG(TAG, " Resolution: %u", this->resolution_);
27 }
28 
29 } // namespace ads1115
30 } // namespace esphome
ADS1115Multiplexer multiplexer_
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
const StringRef & get_name() const
Definition: entity_base.cpp:10