ESPHome 2025.5.0
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 {
6namespace ads1115 {
7
8static const char *const TAG = "ads1115.sensor";
9
11 return this->parent_->request_measurement(this->multiplexer_, this->gain_, this->resolution_, this->samplerate_);
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 ESP_LOGCONFIG(TAG, " Sample rate: %u", this->samplerate_);
28}
29
30} // namespace ads1115
31} // namespace esphome
const StringRef & get_name() const
void publish_state(float state)
Publish a new state to the front-end.
Definition sensor.cpp:39
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7