Fix internal temperature reading on ESP32 (#1391)

The previous macro used SENS_SAR_MEAS_WAIT2_REG to identify if we have the reading capability was not working, so replacing it by a fresh one NO_INT_TEMP_READING, defined as a negation due to the fact that most of the ESP32 supports internal temperature reading.
This commit is contained in:
Florian authored and GitHub committed 2023-01-12 18:05:40 -06:00
1 parent ad97e9a677
commit 76b5e9269f
5 files changed
+8 -6

No files matched your search

+3 -4
View File
@@ -227,8 +227,7 @@ static String ota_server_cert = "";
# include <nvs_flash.h>
bool ProcessLock = false; // Process lock when we want to use a critical function like OTA for example
# if defined(SENS_SAR_MEAS_WAIT2_REG)
# if !defined(NO_INT_TEMP_READING)
// ESP32 internal temperature reading
# include <stdio.h>
@@ -1651,7 +1650,7 @@ unsigned long uptime() {
/**
* Calculate internal ESP32 temperature
*/
#if defined(ESP32) && defined(SENS_SAR_MEAS_WAIT2_REG)
#if defined(ESP32) && !defined(NO_INT_TEMP_READING)
float intTemperatureRead() {
SET_PERI_REG_BITS(SENS_SAR_MEAS_WAIT2_REG, SENS_FORCE_XPD_SAR, 3, SENS_FORCE_XPD_SAR_S);
SET_PERI_REG_BITS(SENS_SAR_TSENS_CTRL_REG, SENS_TSENS_CLK_DIV, 10, SENS_TSENS_CLK_DIV_S);
@@ -1681,7 +1680,7 @@ void stateMeasures() {
SYSdata["mqttport"] = mqtt_port;
SYSdata["mqttsecure"] = mqtt_secure;
# ifdef ESP32
# ifdef SENS_SAR_MEAS_WAIT2_REG // This macro is necessary to retrieve temperature and not present with S3 and C3 environment
# ifndef NO_INT_TEMP_READING
SYSdata["tempc"] = intTemperatureRead();
# endif
SYSdata["freestack"] = uxTaskGetStackHighWaterMark(NULL);