ESPHome 2025.5.0
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, " Multiplexer: %u", this->multiplexer_);
13 ESP_LOGCONFIG(TAG, " Gain: %u", this->gain_);
14}
15
17 return this->parent_->request_measurement(this->multiplexer_, this->gain_, this->temperature_mode_);
18}
19
21 float v = this->sample();
22 if (!std::isnan(v)) {
23 ESP_LOGD(TAG, "'%s': Got Voltage=%fV", this->get_name().c_str(), v);
24 this->publish_state(v);
25 }
26}
27
28} // namespace ads1118
29} // 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