Skip to content

Commit

Permalink
0.8.142
Browse files Browse the repository at this point in the history
* fix compile for ESP8266
  • Loading branch information
lumapu committed Aug 28, 2024
1 parent e64f223 commit 565a69e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/publisher/pubMqtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 5 additions & 0 deletions src/utils/helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ namespace ah {
}
DBGPRINTLN("");
}

float readTemperature() {
/*// ADC1 channel 0 is GPIO36
adc1_config_width(ADC_WIDTH_BIT_12);
Expand All @@ -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
}
}
2 changes: 1 addition & 1 deletion src/web/RestApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 4 additions & 2 deletions src/web/html/system.html
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 565a69e

Please sign in to comment.