diff --git a/src/lib/battery/battery.cpp b/src/lib/battery/battery.cpp index 844f24de74..16b79a6bbd 100644 --- a/src/lib/battery/battery.cpp +++ b/src/lib/battery/battery.cpp @@ -330,6 +330,10 @@ uint16_t Battery::determineFaults() faults |= (1 << battery_status_s::FAULT_SPIKES); } + if (PX4_ISFINITE(_temperature_c) && _temperature_c > BAT_TEMP_MAX) { + faults |= (1 << battery_status_s::FAULT_OVER_TEMPERATURE); + } + return faults; } diff --git a/src/lib/battery/battery.h b/src/lib/battery/battery.h index 66dd73bf27..b432c80e27 100644 --- a/src/lib/battery/battery.h +++ b/src/lib/battery/battery.h @@ -217,4 +217,10 @@ private: static constexpr float OCV_DEFAULT = 4.2f; // [V] Initial per cell estimate of the open circuit voltage static constexpr float R_COVARIANCE = 0.1f; // Initial per cell covariance of the internal resistance static constexpr float OCV_COVARIANCE = 1.5f; // Initial per cell covariance of the open circuit voltage + + // Temperature [degC] above which an overtemperature fault is declared, + // leading to a failsafe warning recommending immediate landing. Note + // that depending on the setup this may be measured in/close to the + // battery (smart battery) or from a separate power monitor module. + static constexpr float BAT_TEMP_MAX = 100.0f; };