Home        Store        Learn        Blog

Mavlink message for battery status

Hi,
I was wondering which mavlink message is used by QGC to draw battery info from Pixhawk. After searching the mavlink message definition, I found the message no: 147 to be handling the battery status from the autopilot. But it says that this message does not output the current from the battery. how does QGC read the current from the battery then?

Hi,

As you can see in the BATTERY_STATUS (#147) message:

id uint8_t Battery ID
battery_function uint8_t Function of the battery
type uint8_t Type (chemistry) of the battery
temperature int16_t Temperature of the battery. INT16_MAX for unknown temperature.
voltages uint16_t[10] Battery voltage of cells. Cells above the valid cell count for this battery should have the UINT16_MAX value.
current_battery int16_t Battery current, -1: autopilot does not measure the current
current_consumed int32_t Consumed charge, -1: autopilot does not provide consumption estimate
energy_consumed int32_t Consumed energy, -1: autopilot does not provide energy consumption estimate
battery_remaining int8_t Remaining battery energy. Values: [0-100], -1: autopilot does not estimate the remaining battery.
time_remaining int32_t Remaining battery time, 0: autopilot does not provide remaining battery time estimate
charge_state uint8_t State for extent of discharge, provided by autopilot for warning or external reactions

The “autopilot does not measure the current” is a reference for the return value of -1. All valid fields will return values different from -1 :slight_smile:

Note that ArduSub does not use the current_consumed field. I’m not sure if we report 0 or -1. The current_battery field is updated, however.

How does QGC do current reporting? Some mavlink message involved?

With BATTERY_STATUS message, ArduSub will send it with all necessary data.

Thanks. :smile: My bad I didn’t read properly

Please let me know if you need any further help.

Patrick, we are trying to read batter voltage with pymavlink. We parse the BATTERY_STATUS message and receive the following:

BATTERY_STATUS {id : 0, battery_function : 0, type : 0, temperature : 32767, voltages : [65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535], current_battery : 49, current_consumed : 4204, energy_consumed : -1, battery_remaining : 47}

The current measurement in centi-amps appears fairly accurate however, the array of voltage values doesn’t contain the measured voltage. We are using the latest version of the power monitor module.

Thanks in advance, Tim

You cannot read the individual cell voltages without a battery monitor that connects to each individual cell. We do not have any experience with this, if you do find one there may be some support issues with ArduSub.

@asjb Are you using ArduCopter or ArduPlane? If so, you will get some better help at discuss.ardupilot.org.

We simply want to read the battery voltage as it appears for example in qGroundControl, but using pymavlink. Please advise. Thanks.

Check SYS_STATUS.

1 Like

Thanks Jacob!