ESPHome
2026.4.0-dev
Loading...
Searching...
No Matches
esphome
components
internal_temperature
internal_temperature_bk72xx.cpp
Go to the documentation of this file.
1
#ifdef USE_BK72XX
2
3
#include "
esphome/core/log.h
"
4
#include "
internal_temperature.h
"
5
6
extern
"C"
{
7
uint32_t
temp_single_get_current_temperature
(
uint32_t
*temp_value);
8
}
9
10
namespace
esphome::internal_temperature
{
11
12
static
const
char
*
const
TAG =
"internal_temperature.bk72xx"
;
13
14
void
InternalTemperatureSensor::update
() {
15
float
temperature
= NAN;
16
bool
success =
false
;
17
18
uint32_t
raw
, result;
19
result =
temp_single_get_current_temperature
(&
raw
);
20
success = (result == 0);
21
#if defined(USE_LIBRETINY_VARIANT_BK7231N)
22
temperature
=
raw
* -0.38f + 156.0f;
23
#elif defined(USE_LIBRETINY_VARIANT_BK7231T)
24
temperature
=
raw
* 0.04f;
25
#else
// USE_LIBRETINY_VARIANT
26
temperature
=
raw
* 0.128f;
27
#endif
// USE_LIBRETINY_VARIANT
28
29
if
(success && std::isfinite(
temperature
)) {
30
this->
publish_state
(temperature);
31
}
else
{
32
ESP_LOGD(TAG,
"Ignoring invalid temperature (success=%d, value=%.1f)"
, success,
temperature
);
33
if
(!this->
has_state
()) {
34
this->
publish_state
(NAN);
35
}
36
}
37
}
38
39
}
// namespace esphome::internal_temperature
40
41
#endif
// USE_BK72XX
raw
uint8_t raw[35]
Definition
bl0939.h:0
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
temp_single_get_current_temperature
uint32_t temp_single_get_current_temperature(uint32_t *temp_value)
log.h
esphome::internal_temperature
Definition
internal_temperature.h:6
uint32_t
static void uint32_t
Definition
crash_handler.cpp:141
temperature
uint16_t temperature
Definition
sun_gtil2.cpp:12
Generated by
1.12.0