ESPHome  2024.4.2
ads1118_sensor.cpp
Go to the documentation of this file.
1 #include "ads1118_sensor.h"
2 
3 #include "esphome/core/log.h"
4 
5 namespace esphome {
6 namespace ads1118 {
7 
8 static 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
ADS1118Multiplexer multiplexer_
void publish_state(float state)
Publish a new state to the front-end.
Definition: sensor.cpp:39
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
const StringRef & get_name() const
Definition: entity_base.cpp:10