ESPHome
2026.4.0-dev
Loading...
Searching...
No Matches
esphome
components
internal_temperature
internal_temperature_rp2040.cpp
Go to the documentation of this file.
1
#ifdef USE_RP2040
2
3
#include "
esphome/core/log.h
"
4
#include "
internal_temperature.h
"
5
6
#include "Arduino.h"
7
8
namespace
esphome::internal_temperature
{
9
10
static
const
char
*
const
TAG =
"internal_temperature.rp2040"
;
11
12
void
InternalTemperatureSensor::update
() {
13
float
temperature
= NAN;
14
bool
success =
false
;
15
16
temperature
= analogReadTemp();
17
success = (
temperature
!= 0.0f);
18
19
if
(success && std::isfinite(
temperature
)) {
20
this->
publish_state
(temperature);
21
}
else
{
22
ESP_LOGD(TAG,
"Ignoring invalid temperature (success=%d, value=%.1f)"
, success,
temperature
);
23
if
(!this->
has_state
()) {
24
this->
publish_state
(NAN);
25
}
26
}
27
}
28
29
}
// namespace esphome::internal_temperature
30
31
#endif
// USE_RP2040
esphome::EntityBase::has_state
bool has_state() const
Definition
entity_base.h:191
esphome::internal_temperature::InternalTemperatureSensor::update
void update() override
Definition
internal_temperature_bk72xx.cpp:14
esphome::sensor::Sensor::publish_state
void publish_state(float state)
Publish a new state to the front-end.
Definition
sensor.cpp:68
internal_temperature.h
log.h
esphome::internal_temperature
Definition
internal_temperature.h:6
temperature
uint16_t temperature
Definition
sun_gtil2.cpp:12
Generated by
1.12.0