ESPHome
2026.5.1
Loading...
Searching...
No Matches
esphome
components
ads1118
sensor
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::ads1118
{
6
7
static
const
char
*
const
TAG =
"ads1118.sensor"
;
8
9
void
ADS1118Sensor::dump_config
() {
10
LOG_SENSOR(
" "
,
"ADS1118 Sensor"
,
this
);
11
ESP_LOGCONFIG(TAG,
12
" Multiplexer: %u\n"
13
" Gain: %u"
,
14
this->
multiplexer_
, this->
gain_
);
15
}
16
17
float
ADS1118Sensor::sample
() {
18
return
this->
parent_
->request_measurement(this->
multiplexer_
, this->
gain_
, this->
temperature_mode_
);
19
}
20
21
void
ADS1118Sensor::update
() {
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
ads1118_sensor.h
esphome::EntityBase::get_name
const StringRef & get_name() const
Definition
entity_base.h:71
esphome::Parented< ADS1118 >::parent_
ADS1118 * parent_
Definition
helpers.h:1872
esphome::ads1118::ADS1118Sensor::dump_config
void dump_config() override
Definition
ads1118_sensor.cpp:9
esphome::ads1118::ADS1118Sensor::sample
float sample() override
Definition
ads1118_sensor.cpp:17
esphome::ads1118::ADS1118Sensor::multiplexer_
ADS1118Multiplexer multiplexer_
Definition
ads1118_sensor.h:29
esphome::ads1118::ADS1118Sensor::gain_
ADS1118Gain gain_
Definition
ads1118_sensor.h:30
esphome::ads1118::ADS1118Sensor::update
void update() override
Definition
ads1118_sensor.cpp:21
esphome::ads1118::ADS1118Sensor::temperature_mode_
bool temperature_mode_
Definition
ads1118_sensor.h:31
esphome::sensor::Sensor::publish_state
void publish_state(float state)
Publish a new state to the front-end.
Definition
sensor.cpp:68
log.h
esphome::ads1118
Definition
ads1118.cpp:5
Generated by
1.12.0