ESPHome 2026.4.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#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
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