From d510cfe26164f12ea5d3558a31ec55d5dffe7d75 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 10 Oct 2021 11:22:53 +0200 Subject: [PATCH] Revert fix ESP32 temperature jump on some devices Revert fix ESP32 temperature jump on some devices. It appears the device makes other non regular jumps too. --- tasmota/support_esp.ino | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/tasmota/support_esp.ino b/tasmota/support_esp.ino index 4a6c2c53b..87db014c0 100644 --- a/tasmota/support_esp.ino +++ b/tasmota/support_esp.ino @@ -478,10 +478,13 @@ void *special_calloc(size_t num, size_t size) { float CpuTemperature(void) { #ifdef CONFIG_IDF_TARGET_ESP32 -// return (float)temperatureRead(); // In Celsius + return (float)temperatureRead(); // In Celsius +/* + // These jumps are not stable either. Sometimes it jumps to 77.3 float t = (float)temperatureRead(); // In Celsius if (t > 81) { t = t - 27.2; } // Fix temp jump observed on some ESP32 like DualR3 return t; +*/ #else // Currently (20210801) repeated calls to temperatureRead() on ESP32C3 and ESP32S2 result in IDF error messages static float t = NAN; @@ -492,6 +495,39 @@ float CpuTemperature(void) { #endif } +/* +#ifdef __cplusplus +extern "C" { +#endif + +uint8_t temprature_sens_read(); + +#ifdef __cplusplus +} +#endif + +#ifdef CONFIG_IDF_TARGET_ESP32 +uint8_t temprature_sens_read(); + +float CpuTemperature(void) { + uint8_t t = temprature_sens_read(); + + AddLog(LOG_LEVEL_DEBUG, PSTR("TMP: value %d"), t); + + return (t - 32) / 1.8; +} +#else +float CpuTemperature(void) { + // Currently (20210801) repeated calls to temperatureRead() on ESP32C3 and ESP32S2 result in IDF error messages + static float t = NAN; + if (isnan(t)) { + t = (float)temperatureRead(); // In Celsius + } + return t; +} +#endif +*/ + /* #if CONFIG_IDF_TARGET_ESP32S2 #include "esp32s2/esp_efuse.h"