mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
add S3 temperature #2077
This commit is contained in:
@@ -97,7 +97,8 @@ const HardwareStatus = () => {
|
|||||||
(data.cpu_cores === 1 ? 'single-core)' : 'dual-core)') +
|
(data.cpu_cores === 1 ? 'single-core)' : 'dual-core)') +
|
||||||
' @ ' +
|
' @ ' +
|
||||||
data.cpu_freq_mhz +
|
data.cpu_freq_mhz +
|
||||||
' Mhz'
|
' Mhz' +
|
||||||
|
(data.temperature ? ', T: ' + data.temperature + ' °C' : '')
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ export interface SystemStatus {
|
|||||||
has_loader: boolean;
|
has_loader: boolean;
|
||||||
has_partition: boolean;
|
has_partition: boolean;
|
||||||
status: string;
|
status: string;
|
||||||
|
temperature?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum LogLevel {
|
export enum LogLevel {
|
||||||
|
|||||||
@@ -458,6 +458,21 @@ void System::start() {
|
|||||||
appused_ = ESP.getSketchSize() / 1024;
|
appused_ = ESP.getSketchSize() / 1024;
|
||||||
appfree_ = esp_ota_get_running_partition()->size / 1024 - appused_;
|
appfree_ = esp_ota_get_running_partition()->size / 1024 - appused_;
|
||||||
refreshHeapMem(); // refresh free heap and max alloc heap
|
refreshHeapMem(); // refresh free heap and max alloc heap
|
||||||
|
#if CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2
|
||||||
|
#if ESP_IDF_VERSION_MAJOR < 5
|
||||||
|
temp_sensor_config_t temp_sensor = TSENS_CONFIG_DEFAULT();
|
||||||
|
temp_sensor_get_config(&temp_sensor);
|
||||||
|
temp_sensor.dac_offset = TSENS_DAC_DEFAULT; // DEFAULT: range:-10℃ ~ 80℃, error < 1℃.
|
||||||
|
temp_sensor_set_config(temp_sensor);
|
||||||
|
temp_sensor_start();
|
||||||
|
temp_sensor_read_celsius(&temperature_);
|
||||||
|
#else
|
||||||
|
temperature_sensor_config_t temp_sensor_config = TEMPERATURE_SENSOR_CONFIG_DEFAULT(-10, 80);
|
||||||
|
temperature_sensor_install(&temp_sensor_config, &temperature_handle_);
|
||||||
|
temperature_sensor_enable(temperature_handle_);
|
||||||
|
temperature_sensor_get_celsius(temperature_handle_, &temperature_);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & networkSettings) {
|
EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & networkSettings) {
|
||||||
@@ -692,6 +707,9 @@ void System::heartbeat_json(JsonObject output) {
|
|||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
output["freemem"] = getHeapMem();
|
output["freemem"] = getHeapMem();
|
||||||
output["max_alloc"] = getMaxAllocMem();
|
output["max_alloc"] = getMaxAllocMem();
|
||||||
|
#if CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2
|
||||||
|
output["temperature"] = temperature_;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
@@ -770,6 +788,16 @@ void System::system_check() {
|
|||||||
if (!last_system_check_ || ((uint32_t)(uuid::get_uptime() - last_system_check_) >= SYSTEM_CHECK_FREQUENCY)) {
|
if (!last_system_check_ || ((uint32_t)(uuid::get_uptime() - last_system_check_) >= SYSTEM_CHECK_FREQUENCY)) {
|
||||||
last_system_check_ = uuid::get_uptime();
|
last_system_check_ = uuid::get_uptime();
|
||||||
|
|
||||||
|
#ifndef EMSESP_STANDALONE
|
||||||
|
#if CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2
|
||||||
|
#if ESP_IDF_VERSION_MAJOR < 5
|
||||||
|
temp_sensor_read_celsius(&temperature_);
|
||||||
|
#else
|
||||||
|
temperature_sensor_get_celsius(temperature_handle_, &temperature_);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef EMSESP_PINGTEST
|
#ifdef EMSESP_PINGTEST
|
||||||
static uint64_t ping_count = 0;
|
static uint64_t ping_count = 0;
|
||||||
LOG_NOTICE("Ping test, #%d", ping_count++);
|
LOG_NOTICE("Ping test, #%d", ping_count++);
|
||||||
@@ -987,6 +1015,9 @@ void System::show_system(uuid::console::Shell & shell) {
|
|||||||
|
|
||||||
shell.printfln(" SDK version: %s", ESP.getSdkVersion());
|
shell.printfln(" SDK version: %s", ESP.getSdkVersion());
|
||||||
shell.printfln(" CPU frequency: %lu MHz", ESP.getCpuFreqMHz());
|
shell.printfln(" CPU frequency: %lu MHz", ESP.getCpuFreqMHz());
|
||||||
|
#if CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2
|
||||||
|
shell.printfln(" CPU temperature: %d °C", (int)temperature());
|
||||||
|
#endif
|
||||||
shell.printfln(" Free heap/Max alloc: %lu KB / %lu KB", getHeapMem(), getMaxAllocMem());
|
shell.printfln(" Free heap/Max alloc: %lu KB / %lu KB", getHeapMem(), getMaxAllocMem());
|
||||||
shell.printfln(" App used/free: %lu KB / %lu KB", appUsed(), appFree());
|
shell.printfln(" App used/free: %lu KB / %lu KB", appUsed(), appFree());
|
||||||
uint32_t FSused = LittleFS.usedBytes() / 1024;
|
uint32_t FSused = LittleFS.usedBytes() / 1024;
|
||||||
@@ -1444,6 +1475,10 @@ bool System::command_info(const char * value, const int8_t id, JsonObject output
|
|||||||
node["freePsram"] = ESP.getFreePsram() / 1024;
|
node["freePsram"] = ESP.getFreePsram() / 1024;
|
||||||
}
|
}
|
||||||
node["model"] = EMSESP::system_.getBBQKeesGatewayDetails();
|
node["model"] = EMSESP::system_.getBBQKeesGatewayDetails();
|
||||||
|
#if CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2
|
||||||
|
node["temperature"] = EMSESP::system_.temperature();
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Network Status
|
// Network Status
|
||||||
|
|||||||
21
src/system.h
21
src/system.h
@@ -39,6 +39,14 @@
|
|||||||
#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 ESP_IDF_VERSION_MAJOR < 5
|
||||||
|
#include "driver/temp_sensor.h"
|
||||||
|
#else
|
||||||
|
#include "driver/temperature_sensor.h"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
using uuid::console::Shell;
|
using uuid::console::Shell;
|
||||||
|
|
||||||
#define EMSESP_FS_CONFIG_DIRECTORY "/config"
|
#define EMSESP_FS_CONFIG_DIRECTORY "/config"
|
||||||
@@ -303,6 +311,12 @@ 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
|
||||||
|
float temperature() {
|
||||||
|
return temperature_;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static uuid::log::Logger logger_;
|
static uuid::log::Logger logger_;
|
||||||
static bool restart_requested_;
|
static bool restart_requested_;
|
||||||
@@ -395,6 +409,13 @@ class System {
|
|||||||
uint32_t psram_;
|
uint32_t psram_;
|
||||||
uint32_t appused_;
|
uint32_t appused_;
|
||||||
uint32_t appfree_;
|
uint32_t appfree_;
|
||||||
|
|
||||||
|
#if CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2
|
||||||
|
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||||
|
temperature_sensor_handle_t temperature_handle_ = NULL;
|
||||||
|
#endif
|
||||||
|
float temperature_ = 0;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace emsesp
|
} // namespace emsesp
|
||||||
|
|||||||
@@ -119,6 +119,9 @@ void WebStatusService::systemStatus(AsyncWebServerRequest * request) {
|
|||||||
root["free_psram"] = ESP.getFreePsram() / 1024;
|
root["free_psram"] = ESP.getFreePsram() / 1024;
|
||||||
}
|
}
|
||||||
root["model"] = EMSESP::system_.getBBQKeesGatewayDetails();
|
root["model"] = EMSESP::system_.getBBQKeesGatewayDetails();
|
||||||
|
#if CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2
|
||||||
|
root["temperature"] = EMSESP::system_.temperature();
|
||||||
|
#endif
|
||||||
|
|
||||||
// check for a factory partition first
|
// check for a factory partition first
|
||||||
const esp_partition_t * partition = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_FACTORY, nullptr);
|
const esp_partition_t * partition = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_FACTORY, nullptr);
|
||||||
|
|||||||
Reference in New Issue
Block a user