Merge pull request #2360 from proddy/dev

implement CPU temp for ESP32
This commit is contained in:
Proddy
2025-01-18 16:13:29 +01:00
committed by GitHub
13 changed files with 42 additions and 27 deletions

View File

@@ -14,6 +14,7 @@ For more details go to [docs.emsesp.org](https://docs.emsesp.org/).
- thermostat `reduce threshold` [#2288](https://github.com/emsesp/EMS-ESP32/issues/2288) - thermostat `reduce threshold` [#2288](https://github.com/emsesp/EMS-ESP32/issues/2288)
- thermostat `absent` [#1957](https://github.com/emsesp/EMS-ESP32/issues/1957) - thermostat `absent` [#1957](https://github.com/emsesp/EMS-ESP32/issues/1957)
- CR11 thermostat [#2295](https://github.com/emsesp/EMS-ESP32/issues/2295) - CR11 thermostat [#2295](https://github.com/emsesp/EMS-ESP32/issues/2295)
- Show ESP32's CPU temp in Hardware Status
## Fixed ## Fixed

View File

@@ -35,7 +35,7 @@
"react": "^19.0.0", "react": "^19.0.0",
"react-dom": "^19.0.0", "react-dom": "^19.0.0",
"react-icons": "^5.4.0", "react-icons": "^5.4.0",
"react-router": "^7.1.2", "react-router": "^7.1.3",
"react-toastify": "^11.0.3", "react-toastify": "^11.0.3",
"typesafe-i18n": "^5.26.2", "typesafe-i18n": "^5.26.2",
"typescript": "^5.7.3" "typescript": "^5.7.3"

View File

@@ -99,7 +99,13 @@ const HardwareStatus = () => {
' @ ' + ' @ ' +
data.cpu_freq_mhz + data.cpu_freq_mhz +
' Mhz' + ' Mhz' +
(data.temperature ? ', T: ' + data.temperature + ' °C' : '') // bit of a hack : if the CPU temp is higher than 90 (=32 Fahrenheit if using Celsius), show F, otherwise C
(data.temperature
? ', T: ' +
data.temperature +
' °' +
(data.temperature > 90 ? 'F' : 'C')
: '')
} }
/> />
</ListItem> </ListItem>

View File

@@ -343,7 +343,7 @@ const de: Translation = {
DEVELOPER_MODE: 'Entwicklermodus', DEVELOPER_MODE: 'Entwicklermodus',
DUPLICATE: 'Kopieren', DUPLICATE: 'Kopieren',
UPGRADE: 'Aktualisieren', UPGRADE: 'Aktualisieren',
DASHBOARD_1: 'All EMS entities that are active and marked as Favorite, plus all Custom Entities, Schedules and external Sensors data are displayed below.', // TODO translate DASHBOARD_1: 'Alle EMS-Entitäten, die aktiv und als Favorit markiert sind, sowie alle benutzerdefinierten Entitäten, Zeitpläne und externen Sensordaten werden unten angezeigt.',
NO_DATA_1: 'Keine favorisierten EMS-Entitäten gefunden! Verwenden Sie das Modul', NO_DATA_1: 'Keine favorisierten EMS-Entitäten gefunden! Verwenden Sie das Modul',
NO_DATA_2: ', um sie zu markieren.', NO_DATA_2: ', um sie zu markieren.',
NO_DATA_3: 'Um alle verfügbaren Entitäten anzuzeigen, gehen Sie zu' NO_DATA_3: 'Um alle verfügbaren Entitäten anzuzeigen, gehen Sie zu'

View File

@@ -1615,7 +1615,7 @@ __metadata:
react: "npm:^19.0.0" react: "npm:^19.0.0"
react-dom: "npm:^19.0.0" react-dom: "npm:^19.0.0"
react-icons: "npm:^5.4.0" react-icons: "npm:^5.4.0"
react-router: "npm:^7.1.2" react-router: "npm:^7.1.3"
react-toastify: "npm:^11.0.3" react-toastify: "npm:^11.0.3"
rollup-plugin-visualizer: "npm:^5.14.0" rollup-plugin-visualizer: "npm:^5.14.0"
terser: "npm:^5.37.0" terser: "npm:^5.37.0"
@@ -5607,9 +5607,9 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"react-router@npm:^7.1.2": "react-router@npm:^7.1.3":
version: 7.1.2 version: 7.1.3
resolution: "react-router@npm:7.1.2" resolution: "react-router@npm:7.1.3"
dependencies: dependencies:
"@types/cookie": "npm:^0.6.0" "@types/cookie": "npm:^0.6.0"
cookie: "npm:^1.0.1" cookie: "npm:^1.0.1"
@@ -5621,7 +5621,7 @@ __metadata:
peerDependenciesMeta: peerDependenciesMeta:
react-dom: react-dom:
optional: true optional: true
checksum: 10c0/f2ef57c8c95cfee0c0689cbcb9a28ebbc5a554831b9e8f9d0295f4c6ac0960a448e16b828dd75168b4e8da228068c99d88248be3418467d6a76ab4ea02bf0d71 checksum: 10c0/f42f7b245533d1adaa00779a0287993a836d5b56039d97a6643a8b3a721ffb92ff47c97cfb36409fec8794ac3c8a884339f588cf21fcd7f6dccdfc834520c76f
languageName: node languageName: node
linkType: hard linkType: hard

View File

@@ -95,8 +95,8 @@ platform = espressif32@6.9.0 ; Arduino Core 2.0.18 / IDF 4.4.8
framework = arduino framework = arduino
board_build.partitions = partitions/esp32_partition_4M.csv board_build.partitions = partitions/esp32_partition_4M.csv
board_upload.flash_size = 4MB board_upload.flash_size = 4MB
platform = https://github.com/tasmota/platform-espressif32/releases/download/2024.06.00/platform-espressif32.zip ; Arduino Core 2.0.18 with IPv6 support, based on IDF 4.4.8 platform = https://github.com/tasmota/platform-espressif32/releases/download/2024.06.00/platform-espressif32.zip ; Arduino Core 2.0.18 with IPv6 support, based on IDF 4.4.8
; platform = https://github.com/tasmota/platform-espressif32/releases/download/2024.12.30/platform-espressif32.zip ; Arduino Core 3.1.0.241206 based on IDF 5.3.2 ; platform = https://github.com/tasmota/platform-espressif32/releases/download/2025.01.31/platform-espressif32.zip ; Arduino Core 3.1.1, based on IDF 5.3.2
; use Tasmota's library for 16MB Flash variants. ; use Tasmota's library for 16MB Flash variants.
; Removes libs (like mbedtsl, so no WiFi_secure.h) to increase available heap ; Removes libs (like mbedtsl, so no WiFi_secure.h) to increase available heap

View File

@@ -33,7 +33,7 @@ char * Helpers::hextoa(char * result, const uint8_t value) {
return result; return result;
} }
// same as above but to a hex string // same as hextoa but uses to a hex std::string
std::string Helpers::hextoa(const uint8_t value, bool prefix) { std::string Helpers::hextoa(const uint8_t value, bool prefix) {
char buf[3]; char buf[3];
if (prefix) { if (prefix) {

View File

@@ -51,7 +51,7 @@ class Helpers {
static uint16_t string2minutes(const std::string & str); static uint16_t string2minutes(const std::string & str);
static float numericoperator2scalefactor(int8_t numeric_operator); static float numericoperator2scalefactor(int8_t numeric_operator);
static double transformNumFloat(double value, const int8_t numeric_operator, const uint8_t fahrenheit = 0); static double transformNumFloat(double value, const int8_t numeric_operator = 0, const uint8_t fahrenheit = 0);
static std::string toLower(std::string const & s); static std::string toLower(std::string const & s);
static std::string toUpper(std::string const & s); static std::string toUpper(std::string const & s);

View File

@@ -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

View File

@@ -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

View File

@@ -517,25 +517,25 @@ void WebCustomEntityService::generate_value_web(JsonObject output, const bool is
} }
case DeviceValueType::INT8: case DeviceValueType::INT8:
if ((int8_t)entity.value != EMS_VALUE_INT8_NOTSET) { if ((int8_t)entity.value != EMS_VALUE_INT8_NOTSET) {
obj["v"] = Helpers::transformNumFloat(entity.factor * (int8_t)entity.value, 0); obj["v"] = Helpers::transformNumFloat(entity.factor * (int8_t)entity.value);
include = true; include = true;
} }
break; break;
case DeviceValueType::UINT8: case DeviceValueType::UINT8:
if ((uint8_t)entity.value != EMS_VALUE_UINT8_NOTSET) { if ((uint8_t)entity.value != EMS_VALUE_UINT8_NOTSET) {
obj["v"] = Helpers::transformNumFloat(entity.factor * (uint8_t)entity.value, 0); obj["v"] = Helpers::transformNumFloat(entity.factor * (uint8_t)entity.value);
include = true; include = true;
} }
break; break;
case DeviceValueType::INT16: case DeviceValueType::INT16:
if ((int16_t)entity.value != EMS_VALUE_INT16_NOTSET) { if ((int16_t)entity.value != EMS_VALUE_INT16_NOTSET) {
obj["v"] = Helpers::transformNumFloat(entity.factor * (int16_t)entity.value, 0); obj["v"] = Helpers::transformNumFloat(entity.factor * (int16_t)entity.value);
include = true; include = true;
} }
break; break;
case DeviceValueType::UINT16: case DeviceValueType::UINT16:
if ((uint16_t)entity.value != EMS_VALUE_UINT16_NOTSET) { if ((uint16_t)entity.value != EMS_VALUE_UINT16_NOTSET) {
obj["v"] = Helpers::transformNumFloat(entity.factor * (uint16_t)entity.value, 0); obj["v"] = Helpers::transformNumFloat(entity.factor * (uint16_t)entity.value);
include = true; include = true;
} }
break; break;
@@ -543,7 +543,7 @@ void WebCustomEntityService::generate_value_web(JsonObject output, const bool is
case DeviceValueType::TIME: case DeviceValueType::TIME:
case DeviceValueType::UINT32: case DeviceValueType::UINT32:
if (entity.value != EMS_VALUE_UINT24_NOTSET) { if (entity.value != EMS_VALUE_UINT24_NOTSET) {
obj["v"] = Helpers::transformNumFloat(entity.factor * entity.value, 0); obj["v"] = Helpers::transformNumFloat(entity.factor * entity.value);
include = true; include = true;
} }
break; break;

View File

@@ -145,7 +145,7 @@ void WebDataService::sensor_data(AsyncWebServerRequest * request) {
obj["t"] = sensor.type(); obj["t"] = sensor.type();
if (sensor.type() != AnalogSensor::AnalogType::NOTUSED) { if (sensor.type() != AnalogSensor::AnalogType::NOTUSED) {
obj["v"] = Helpers::transformNumFloat(sensor.value(), 0); // is optional and is a float obj["v"] = Helpers::transformNumFloat(sensor.value()); // is optional and is a float
} else { } else {
obj["v"] = 0; // must have a value for web sorting to work obj["v"] = 0; // must have a value for web sorting to work
} }
@@ -423,11 +423,11 @@ void WebDataService::dashboard_data(AsyncWebServerRequest * request) {
dv["id"] = "00" + sensor.name(); dv["id"] = "00" + sensor.name();
#if CONFIG_IDF_TARGET_ESP32 #if CONFIG_IDF_TARGET_ESP32
if (sensor.type() == AnalogSensor::AnalogType::DIGITAL_OUT && (sensor.gpio() == 25 || sensor.gpio() == 26)) { if (sensor.type() == AnalogSensor::AnalogType::DIGITAL_OUT && (sensor.gpio() == 25 || sensor.gpio() == 26)) {
obj["v"] = Helpers::transformNumFloat(sensor.value(), 0); obj["v"] = Helpers::transformNumFloat(sensor.value());
} else } else
#elif CONFIG_IDF_TARGET_ESP32S2 #elif CONFIG_IDF_TARGET_ESP32S2
if (sensor.type() == AnalogSensor::AnalogType::DIGITAL_OUT && (sensor.gpio() == 17 || sensor.gpio() == 18)) { if (sensor.type() == AnalogSensor::AnalogType::DIGITAL_OUT && (sensor.gpio() == 17 || sensor.gpio() == 18)) {
obj["v"] = Helpers::transformNumFloat(sensor.value(), 0); obj["v"] = Helpers::transformNumFloat(sensor.value());
} else } else
#endif #endif
if (sensor.type() == AnalogSensor::AnalogType::DIGITAL_OUT || sensor.type() == AnalogSensor::AnalogType::DIGITAL_IN) { if (sensor.type() == AnalogSensor::AnalogType::DIGITAL_OUT || sensor.type() == AnalogSensor::AnalogType::DIGITAL_IN) {
@@ -437,7 +437,7 @@ void WebDataService::dashboard_data(AsyncWebServerRequest * request) {
l.add(Helpers::render_boolean(s, false, true)); l.add(Helpers::render_boolean(s, false, true));
l.add(Helpers::render_boolean(s, true, true)); l.add(Helpers::render_boolean(s, true, true));
} else { } else {
dv["v"] = Helpers::transformNumFloat(sensor.value(), 0); dv["v"] = Helpers::transformNumFloat(sensor.value());
dv["u"] = sensor.uom(); dv["u"] = sensor.uom();
} }
if (sensor.type() == AnalogSensor::AnalogType::COUNTER || sensor.type() >= AnalogSensor::AnalogType::DIGITAL_OUT) { if (sensor.type() == AnalogSensor::AnalogType::COUNTER || sensor.type() >= AnalogSensor::AnalogType::DIGITAL_OUT) {

View File

@@ -130,8 +130,8 @@ 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 #if CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32
root["temperature"] = EMSESP::system_.temperature(); root["temperature"] = Helpers::transformNumFloat(EMSESP::system_.temperature(), 0, EMSESP::system_.fahrenheit() ? 2 : 0); // only 2 decimal places
#endif #endif
// check for a factory partition first // check for a factory partition first