diff --git a/platforms/common/include/px4_platform_common/board_common.h b/platforms/common/include/px4_platform_common/board_common.h index aaf47003164..be9e5533853 100644 --- a/platforms/common/include/px4_platform_common/board_common.h +++ b/platforms/common/include/px4_platform_common/board_common.h @@ -137,6 +137,12 @@ # define BOARD_ADC_OPEN_CIRCUIT_V (1.5f) #endif +/* Define the default ESC-reported battery voltage at or below which no battery is considered connected */ + +#if !defined(BOARD_ESC_BATTERY_OPEN_CIRCUIT_V) +# define BOARD_ESC_BATTERY_OPEN_CIRCUIT_V (0.0f) +#endif + /* Define the default Under voltage Window on the LTC4417 as set by resistors on the * board. Default is that of the FMUv2 at 3.7V */ diff --git a/src/modules/esc_battery/EscBattery.cpp b/src/modules/esc_battery/EscBattery.cpp index a2c38d898ef..4397421f59e 100644 --- a/src/modules/esc_battery/EscBattery.cpp +++ b/src/modules/esc_battery/EscBattery.cpp @@ -111,7 +111,7 @@ EscBattery::Run() average_voltage_v /= online_esc_count; - _battery.setConnected(true); + _battery.setConnected(average_voltage_v > BOARD_ESC_BATTERY_OPEN_CIRCUIT_V); _battery.updateVoltage(average_voltage_v); _battery.updateCurrent(total_current_a); _battery.updateAndPublishBatteryStatus(esc_status.timestamp);