diff --git a/src/publisher/pubMqtt.h b/src/publisher/pubMqtt.h index f593e620..04494d7d 100644 --- a/src/publisher/pubMqtt.h +++ b/src/publisher/pubMqtt.h @@ -158,8 +158,9 @@ class PubMqtt { publish(subtopics[MQTT_UPTIME], mVal.data()); publish(subtopics[MQTT_RSSI], String(WiFi.RSSI()).c_str()); publish(subtopics[MQTT_FREE_HEAP], String(ESP.getFreeHeap()).c_str()); + #if defined(ESP32) publish(subtopics[MQTT_TEMP_SENS_C], String(ah::readTemperature()).c_str()); - #ifndef ESP32 + #else ESP32 publish(subtopics[MQTT_HEAP_FRAG], String(ESP.getHeapFragmentation()).c_str()); #endif } diff --git a/src/utils/helper.cpp b/src/utils/helper.cpp index 7fd025d8..7d0c2cfb 100644 --- a/src/utils/helper.cpp +++ b/src/utils/helper.cpp @@ -142,6 +142,7 @@ namespace ah { } DBGPRINTLN(""); } + float readTemperature() { /*// ADC1 channel 0 is GPIO36 adc1_config_width(ADC_WIDTH_BIT_12); @@ -155,6 +156,10 @@ namespace ah { // This formula is an approximation and might need to be calibrated for your specific use case. float temperature = (voltage - 500) / 10.0;*/ + #if defined(ESP_32) return temperatureRead(); + #else + return 0; + #endif } } diff --git a/src/web/RestApi.h b/src/web/RestApi.h index b3d9df1f..a868b31c 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -822,9 +822,9 @@ class RestApi { void getChipInfo(JsonObject obj) { obj[F("cpu_freq")] = ESP.getCpuFreqMHz(); obj[F("sdk")] = ESP.getSdkVersion(); - obj[F("temp_sensor_c")] = ah::readTemperature(); #if defined(ESP32) + obj[F("temp_sensor_c")] = ah::readTemperature(); obj[F("revision")] = ESP.getChipRevision(); obj[F("model")] = ESP.getChipModel(); obj[F("cores")] = ESP.getChipCores(); diff --git a/src/web/html/system.html b/src/web/html/system.html index daaa5e05..2e5d44a8 100644 --- a/src/web/html/system.html +++ b/src/web/html/system.html @@ -44,8 +44,10 @@ tr("{#ENVIRONMENT}", obj.generic.env + " ({#BUILD_OPTIONS}: " + obj.generic.modules + ")"), tr("Version", obj.generic.version + " - " + obj.generic.build), tr("Chip", "CPU: " + obj.chip.cpu_freq + "MHz, " + obj.chip.cores + " Core(s)"), - tr("Chip Model", obj.chip.model), - tr("Chip temp.", obj.chip.temp_sensor_c + "°C"), + tr("Chip Model", obj.chip.model) + /*IF_ESP32*/ + ,tr("Chip temp.", obj.chip.temp_sensor_c + "°C") + /*ENDIF_ESP32*/ ] document.getElementById("info").append(