Add ESP32 Cpu Temperature

This commit is contained in:
Theo Arends 2021-04-12 14:59:40 +02:00
parent ab33b394f2
commit 591021a556
2 changed files with 19 additions and 1 deletions

View File

@ -457,7 +457,6 @@ uint8_t* FlashDirectAccess(void) {
return data;
}
void *special_malloc(uint32_t size) {
if (psramFound()) {
return heap_caps_malloc(size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
@ -473,6 +472,20 @@ void *special_realloc(void *ptr, size_t size) {
}
}
#ifdef __cplusplus
extern "C" {
#endif
uint8_t temprature_sens_read(); // librtc.a(rtc_analog.o)
#ifdef __cplusplus
}
#endif
float CpuTemperature(void) {
// return ConvertTemp(temperatureRead());
uint8_t tf = temprature_sens_read(); // Fahrenheit
return ConvertTemp(((float)(tf -32) / 1.8));
}
#endif // ESP32
/*********************************************************************************************\

View File

@ -821,6 +821,11 @@ bool MqttShowSensor(void)
{
ResponseAppendTime();
#ifdef ESP32
float t = CpuTemperature();
ResponseAppend_P(PSTR(",\"Cpu" D_JSON_TEMPERATURE "\":%*_f"), Settings.flag2.temperature_resolution, &t);
#endif
int json_data_start = strlen(TasmotaGlobal.mqtt_data);
for (uint32_t i = 0; i < MAX_SWITCHES; i++) {
#ifdef USE_TM1638