ESPHome 2026.2.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 {
6namespace ads1118 {
7
8static const char *const TAG = "ads1118.sensor";
9
11 LOG_SENSOR(" ", "ADS1118 Sensor", this);
12 ESP_LOGCONFIG(TAG,
13 " Multiplexer: %u\n"
14 " Gain: %u",
15 this->multiplexer_, this->gain_);
16}
17
19 return this->parent_->request_measurement(this->multiplexer_, this->gain_, this->temperature_mode_);
20}
21
23 float v = this->sample();
24 if (!std::isnan(v)) {
25 ESP_LOGD(TAG, "'%s': Got Voltage=%fV", this->get_name().c_str(), v);
26 this->publish_state(v);
27 }
28}
29
30} // namespace ads1118
31} // namespace esphome
const StringRef & get_name() const
void publish_state(float state)
Publish a new state to the front-end.
Definition sensor.cpp:65
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7