ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
internal_temperature_bk72xx.cpp
Go to the documentation of this file.
1#ifdef USE_BK72XX
2
3#include "esphome/core/log.h"
5
6extern "C" {
8}
9
11
12static const char *const TAG = "internal_temperature.bk72xx";
13
15 float temperature = NAN;
16 bool success = false;
17
18 uint32_t raw, result;
20 success = (result == 0);
21#if defined(USE_LIBRETINY_VARIANT_BK7231N)
22 temperature = raw * -0.38f + 156.0f;
23#else // USE_LIBRETINY_VARIANT
24 temperature = raw * 0.128f;
25#endif // USE_LIBRETINY_VARIANT
26
27 if (success && std::isfinite(temperature)) {
28 this->publish_state(temperature);
29 } else {
30 ESP_LOGD(TAG, "Ignoring invalid temperature (success=%d, value=%.1f)", success, temperature);
31 if (!this->has_state()) {
32 this->publish_state(NAN);
33 }
34 }
35}
36
37} // namespace esphome::internal_temperature
38
39#endif // USE_BK72XX
uint8_t raw[35]
Definition bl0939.h:0
bool has_state() const
void publish_state(float state)
Publish a new state to the front-end.
Definition sensor.cpp:68
uint32_t temp_single_get_current_temperature(uint32_t *temp_value)
static void uint32_t
uint16_t temperature
Definition sun_gtil2.cpp:12