ESPHome 2026.5.1
Loading...
Searching...
No Matches
ads1118_sensor.cpp
Go to the documentation of this file.
1#include "ads1118_sensor.h"
2
3#include "esphome/core/log.h"
4
5namespace esphome::ads1118 {
6
7static const char *const TAG = "ads1118.sensor";
8
10 LOG_SENSOR(" ", "ADS1118 Sensor", this);
11 ESP_LOGCONFIG(TAG,
12 " Multiplexer: %u\n"
13 " Gain: %u",
14 this->multiplexer_, this->gain_);
15}
16
18 return this->parent_->request_measurement(this->multiplexer_, this->gain_, this->temperature_mode_);
19}
20
22 float v = this->sample();
23 if (!std::isnan(v)) {
24 ESP_LOGD(TAG, "'%s': Got Voltage=%fV", this->get_name().c_str(), v);
25 this->publish_state(v);
26 }
27}
28
29} // namespace esphome::ads1118
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