ESPHome 2026.11.0-dev
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
7ESPHOME_LOG_TAG(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", LOG_STR_ARG(this->get_log_name()), v);
25 this->publish_state(v);
26 }
27}
28
29} // namespace esphome::ads1118
const LogString * get_log_name() const
Get the name for a "%s" log argument (LOG_STR_ARG).
void publish_state(float state)
Publish a new state to the front-end.
Definition sensor.cpp:65
ESPHOME_LOG_TAG(TAG, "ads1118")