Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[P026][Sysvars] Add Internal temperature sensor value for ESP32 #4820

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 16 additions & 16 deletions src/_P026_Sysinfo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -213,23 +213,23 @@ boolean Plugin_026(uint8_t function, struct EventStruct *event, String& string)
// return decode(bytes,
// [header, uint24, uint24, int8, vcc, pct_8, uint8, uint8, uint8, uint8, uint24, uint16],
// ['header', 'uptime', 'freeheap', 'rssi', 'vcc', 'load', 'ip1', 'ip2', 'ip3', 'ip4', 'web', 'freestack']);
// on ESP32 you can add 'internaltemperature' of type int16 (1e2) to the list
// on ESP32 you can add 'internaltemperature' of type int16 (1e2) to the list (disabled for now, so not available)
uint8_t index = 0;
string += LoRa_addInt(P026_get_value(index++), PackedData_uint24); // uptime
string += LoRa_addInt(P026_get_value(index++), PackedData_uint24); // freeheap
string += LoRa_addFloat(P026_get_value(index++), PackedData_int8); // rssi
string += LoRa_addFloat(P026_get_value(index++), PackedData_vcc); // vcc
string += LoRa_addFloat(P026_get_value(index++), PackedData_pct_8); // load
string += LoRa_addInt(P026_get_value(index++), PackedData_uint8); // ip1
string += LoRa_addInt(P026_get_value(index++), PackedData_uint8); // ip2
string += LoRa_addInt(P026_get_value(index++), PackedData_uint8); // ip3
string += LoRa_addInt(P026_get_value(index++), PackedData_uint8); // ip4
string += LoRa_addInt(P026_get_value(index++), PackedData_uint24); // web
string += LoRa_addInt(P026_get_value(index++), PackedData_uint16); // freestack
# if FEATURE_INTERNAL_TEMPERATURE
string += LoRa_addInt(P026_get_value(index++) * 100.0f, PackedData_int16_1e2); // internal temperature in 0.01 degrees
# endif // if FEATURE_INTERNAL_TEMPERATURE
event->Par1 = index; // valuecount
string += LoRa_addInt(P026_get_value(index++), PackedData_uint24); // uptime
string += LoRa_addInt(P026_get_value(index++), PackedData_uint24); // freeheap
string += LoRa_addFloat(P026_get_value(index++), PackedData_int8); // rssi
string += LoRa_addFloat(P026_get_value(index++), PackedData_vcc); // vcc
string += LoRa_addFloat(P026_get_value(index++), PackedData_pct_8); // load
string += LoRa_addInt(P026_get_value(index++), PackedData_uint8); // ip1
string += LoRa_addInt(P026_get_value(index++), PackedData_uint8); // ip2
string += LoRa_addInt(P026_get_value(index++), PackedData_uint8); // ip3
string += LoRa_addInt(P026_get_value(index++), PackedData_uint8); // ip4
string += LoRa_addInt(P026_get_value(index++), PackedData_uint24); // web
string += LoRa_addInt(P026_get_value(index++), PackedData_uint16); // freestack
// # if FEATURE_INTERNAL_TEMPERATURE
// string += LoRa_addInt(P026_get_value(index++) * 100.0f, PackedData_int16_1e2); // internal temperature in 0.01 degrees
// # endif // if FEATURE_INTERNAL_TEMPERATURE
event->Par1 = index; // valuecount
success = true;
break;
}
Expand Down
8 changes: 4 additions & 4 deletions src/src/Helpers/Hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,22 +623,22 @@ uint8_t temprature_sens_read();

float getInternalTemperature() {
tonhuisman marked this conversation as resolved.
Show resolved Hide resolved
float temperature = -273.15f; // Inprobable value
tonhuisman marked this conversation as resolved.
Show resolved Hide resolved
bool success;
#ifdef ESP32
#if defined(ESP32_CLASSIC)
uint8_t raw = temprature_sens_read();
#ifndef BUILD_NO_DEBUG
addLog(LOG_LEVEL_DEBUG, concat(F("ESP32: Raw temperature value: "), raw));
#endif
success = (raw != 128);
temperature = (raw - 32) / 1.8f;
if (raw != 128) {
temperature = (raw - 32) / 1.8f;
}
#elif defined(ESP32C3) || defined(ESP32S2) || defined(ESP32S3)
temp_sensor_config_t tsens = TSENS_CONFIG_DEFAULT();
temp_sensor_set_config(tsens);
temp_sensor_start();
esp_err_t result = temp_sensor_read_celsius(&temperature);
temp_sensor_stop();
if (result = ESP_OK) {
if (result != ESP_OK) {
temperature = -273.15f;
tonhuisman marked this conversation as resolved.
Show resolved Hide resolved
}
#endif // ESP32_CLASSIC
Expand Down
2 changes: 1 addition & 1 deletion src/src/Helpers/SystemVariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ const __FlashStringHelper * SystemVariables::toFlashString(SystemVariables::Enum
case Enum::ISNTP: return F("isntp");
case Enum::ISWIFI: return F("iswifi");
#if FEATURE_INTERNAL_TEMPERATURE
case Enum::INTERNAL_TEMPERATURE: return F("internaltemperature");
case Enum::INTERNAL_TEMPERATURE: return F("inttemp");
#endif // if FEATURE_INTERNAL_TEMPERATURE
#if FEATURE_ETHERNET
case Enum::ETHWIFIMODE: return F("ethwifimode");
Expand Down