Browse Source

0.8.142

* fix compile for ESP8266
pull/1745/head
lumapu 5 months ago
parent
commit
565a69e5c0
  1. 3
      src/publisher/pubMqtt.h
  2. 5
      src/utils/helper.cpp
  3. 2
      src/web/RestApi.h
  4. 6
      src/web/html/system.html

3
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
}

5
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
}
}

2
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();

6
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(

Loading…
Cancel
Save