From 50e3ce4c809489a5cd2b0166d7120d1c990d0c0d Mon Sep 17 00:00:00 2001 From: Mat931 <49403702+Mat931@users.noreply.github.com> Date: Mon, 22 Apr 2024 20:59:06 +0000 Subject: [PATCH] Calibrate Beken internal temperature (#6599) --- .../internal_temperature/internal_temperature.cpp | 8 +++++--- tests/components/internal_temperature/test.bk72xx.yaml | 3 +++ .../internal_temperature/test.esp32-c3-idf.yaml | 3 +++ tests/components/internal_temperature/test.esp32-c3.yaml | 3 +++ tests/components/internal_temperature/test.esp32-idf.yaml | 3 +++ tests/components/internal_temperature/test.esp32.yaml | 3 +++ tests/components/internal_temperature/test.rp2040.yaml | 3 +++ 7 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 tests/components/internal_temperature/test.bk72xx.yaml create mode 100644 tests/components/internal_temperature/test.esp32-c3-idf.yaml create mode 100644 tests/components/internal_temperature/test.esp32-c3.yaml create mode 100644 tests/components/internal_temperature/test.esp32-idf.yaml create mode 100644 tests/components/internal_temperature/test.esp32.yaml create mode 100644 tests/components/internal_temperature/test.rp2040.yaml diff --git a/esphome/components/internal_temperature/internal_temperature.cpp b/esphome/components/internal_temperature/internal_temperature.cpp index 255d95f6f8..47f516f568 100644 --- a/esphome/components/internal_temperature/internal_temperature.cpp +++ b/esphome/components/internal_temperature/internal_temperature.cpp @@ -55,11 +55,13 @@ void InternalTemperatureSensor::update() { uint32_t raw, result; result = temp_single_get_current_temperature(&raw); success = (result == 0); -#ifdef USE_LIBRETINY_VARIANT_BK7231T +#if defined(USE_LIBRETINY_VARIANT_BK7231N) + temperature = raw * -0.38f + 156.0f; +#elif defined(USE_LIBRETINY_VARIANT_BK7231T) temperature = raw * 0.04f; -#else +#else // USE_LIBRETINY_VARIANT temperature = raw * 0.128f; -#endif // USE_LIBRETINY_VARIANT_BK7231T +#endif // USE_LIBRETINY_VARIANT #endif // USE_BK72XX if (success && std::isfinite(temperature)) { this->publish_state(temperature); diff --git a/tests/components/internal_temperature/test.bk72xx.yaml b/tests/components/internal_temperature/test.bk72xx.yaml new file mode 100644 index 0000000000..28df4a6d9f --- /dev/null +++ b/tests/components/internal_temperature/test.bk72xx.yaml @@ -0,0 +1,3 @@ +sensor: + - platform: internal_temperature + name: "Internal Temperature" diff --git a/tests/components/internal_temperature/test.esp32-c3-idf.yaml b/tests/components/internal_temperature/test.esp32-c3-idf.yaml new file mode 100644 index 0000000000..28df4a6d9f --- /dev/null +++ b/tests/components/internal_temperature/test.esp32-c3-idf.yaml @@ -0,0 +1,3 @@ +sensor: + - platform: internal_temperature + name: "Internal Temperature" diff --git a/tests/components/internal_temperature/test.esp32-c3.yaml b/tests/components/internal_temperature/test.esp32-c3.yaml new file mode 100644 index 0000000000..28df4a6d9f --- /dev/null +++ b/tests/components/internal_temperature/test.esp32-c3.yaml @@ -0,0 +1,3 @@ +sensor: + - platform: internal_temperature + name: "Internal Temperature" diff --git a/tests/components/internal_temperature/test.esp32-idf.yaml b/tests/components/internal_temperature/test.esp32-idf.yaml new file mode 100644 index 0000000000..28df4a6d9f --- /dev/null +++ b/tests/components/internal_temperature/test.esp32-idf.yaml @@ -0,0 +1,3 @@ +sensor: + - platform: internal_temperature + name: "Internal Temperature" diff --git a/tests/components/internal_temperature/test.esp32.yaml b/tests/components/internal_temperature/test.esp32.yaml new file mode 100644 index 0000000000..28df4a6d9f --- /dev/null +++ b/tests/components/internal_temperature/test.esp32.yaml @@ -0,0 +1,3 @@ +sensor: + - platform: internal_temperature + name: "Internal Temperature" diff --git a/tests/components/internal_temperature/test.rp2040.yaml b/tests/components/internal_temperature/test.rp2040.yaml new file mode 100644 index 0000000000..28df4a6d9f --- /dev/null +++ b/tests/components/internal_temperature/test.rp2040.yaml @@ -0,0 +1,3 @@ +sensor: + - platform: internal_temperature + name: "Internal Temperature"