mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
implement CPU temp for ESP32
This commit is contained in:
@@ -789,7 +789,10 @@ void System::system_check() {
|
|||||||
last_system_check_ = uuid::get_uptime();
|
last_system_check_ = uuid::get_uptime();
|
||||||
|
|
||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
#if CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2
|
#if defined(CONFIG_IDF_TARGET_ESP32)
|
||||||
|
uint8_t raw = temprature_sens_read();
|
||||||
|
temperature_ = (raw - 32) / 1.8f; // convert to Celsius
|
||||||
|
#elif CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2
|
||||||
#if ESP_IDF_VERSION_MAJOR < 5
|
#if ESP_IDF_VERSION_MAJOR < 5
|
||||||
temp_sensor_read_celsius(&temperature_);
|
temp_sensor_read_celsius(&temperature_);
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -39,7 +39,12 @@
|
|||||||
#include <uuid/log.h>
|
#include <uuid/log.h>
|
||||||
#include <PButton.h>
|
#include <PButton.h>
|
||||||
|
|
||||||
#if CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2
|
#if defined(CONFIG_IDF_TARGET_ESP32)
|
||||||
|
// there is no official API available on the original ESP32
|
||||||
|
extern "C" {
|
||||||
|
uint8_t temprature_sens_read();
|
||||||
|
}
|
||||||
|
#elif CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2
|
||||||
#if ESP_IDF_VERSION_MAJOR < 5
|
#if ESP_IDF_VERSION_MAJOR < 5
|
||||||
#include "driver/temp_sensor.h"
|
#include "driver/temp_sensor.h"
|
||||||
#else
|
#else
|
||||||
@@ -331,7 +336,7 @@ class System {
|
|||||||
test_set_all_active_ = n;
|
test_set_all_active_ = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2
|
#if CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32
|
||||||
float temperature() {
|
float temperature() {
|
||||||
return temperature_;
|
return temperature_;
|
||||||
}
|
}
|
||||||
@@ -435,8 +440,8 @@ class System {
|
|||||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||||
temperature_sensor_handle_t temperature_handle_ = NULL;
|
temperature_sensor_handle_t temperature_handle_ = NULL;
|
||||||
#endif
|
#endif
|
||||||
float temperature_ = 0;
|
|
||||||
#endif
|
#endif
|
||||||
|
float temperature_ = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace emsesp
|
} // namespace emsesp
|
||||||
|
|||||||
Reference in New Issue
Block a user