Read BATTERY2 Mavlink

I have all hardware connect, but how can I read BATTERY2 Mavlink values in mission planner or MinimOSD?

Hello everyone,

For those who wants to read a second battery Voltage and show it on OSD…

I have a Remzibi OSD with MinimOSD software ported to real C+, so next explanation is not exactly the same for an Arduino based device like MinimOSD, but it must works. Just you have to do is implement in your code a “case” to read MSG_ID_BATTERY2 from Mavlink datastream.

On first, update your Mavlink libraries from code repository on GitHUB.

Then add this to MAVLINK.ino:

case MAVLINK_MSG_ID_BATTERY2:
  {
    osd_vbat_B = (mavlink_msg_battery2_get_voltage(msg)/1000.0f);
    osd_curr_B = (mavlink_msg_battery2_get_current_battery(msg)/100.0f);
  }

Next you have to do is define in OSD_Vars.h the new variables and panel coordinate holders:

static float osd_vbat_B = 0; // voltage in milivolt
static int16_t osd_curr_B = 0; // Battery B current

byte panBatt_B_XY[2]; // = { 23,3 };
byte panCur_B_XY[2]; // = { 23,4 };

And finally, add a new OSD panel in OSD_Panels.ino:

if(ISa(panel,BatB_BIT)) panBatt_B(panBatt_B_XY[0], panBatt_B_XY[1][panel]); //7x1

/* **************************************************************** */
// Panel : panBattery B (Voltage 2)
// Needs : X, Y locations
// Output : Voltage value as in XX.X and symbol of over all battery status
// Size : 1 x 8 (rows x chars)
// Staus : done
void panBatt_B(int first_col, int first_line){
osd.setPanel(first_col, first_line);
osd.openPanel();
osd.printf("%5.2f%c", (double)osd_vbat_B, 0x0d);
osd.closePanel();
}

Remember to assign unused coordinates to the new panel…
This is not plug and play code… you need to modify it for your conveniences.

Of course you have to activate and config BATTERY2 readings in Ardupilot with APM Planner or Mission Planner GCS Software.

Regards from Spain,
Dario.