Hi all,

I'm currently setting up the Ardupilot on a Skywalker, and as always I will use a separate battery for camera/OSD/VTx. I am flying with a 4S LiPo and am trying to avoid step down converters and filters.

Are there any plans to add monitoring of a second battery to the APM code? I have seen people mention that it will be implemented, but those posts are over 6 months old. I have also looked at the MinimOSD Extra source code and there are lines with "osd_vbat_B" commented out.

It shouldn't be that hard to implement, but if someone else has already started coding it it would be nice to know.

The obvious way to connect a second battery is through a voltage divider to a free analog input port on the APM.



Views: 5360

Reply to This

Replies to This Discussion


     As you say, we've talked about it but nobody's done it yet.  Rob Lefebvre was the volunteer for that.

     By the way, we think it's a common enough function that it should be added into the AP_BattMonitor library.

I have now started implementing monitoring of a second battery in ArduPlane.

If someone is interested you can look at my repository here:


At the moment the sketch is too big for the Ardupilot, but I (or someone smarter than me) can hopefully soon fix this problem!

I haven't reviewed the code but great that you're looking at it.

I think to get the size down we are going to need to remove the CLI.  We're already started on this but not there yet.

Thanks. The code compiles and the aux battery voltage should be sent via an extended MavLink status message, and a low aux battery voltage should trigger an alarm. But of course I cannot test it until I can merge a smaller ArduPlane sketch with my fork.

I will also try to make the code smaller by making the voltage monitoring code reusable. Right now I just copy-pasted the code for the main battery and made small changes. Using pointers/references I should hopefully get the sketch size down a couple of kB, but i doubt it will be enough...

I got a tip from Robert Lefebvre who told me to use the gcc 4.7.2-version of the Arduino IDE to compile the code, and now the sketch is small enough! (238 012 bytes of 258 048)

Now I just need a voltage divider to connect a 3S battery to an analog port. Hopefully I can find a way to look at the MavLink messages to see if the correct voltage is sent.

I have now successfully tested the aux battery monitoring by looking at the SYS_STATUS message. I can set the parameters in the all config parameters tab in Mission Planner, which means I can enable monitoring and set voltage multiplier value.

However, I cannot see the voltage received via MavLink in the Mission Planner. This almost certainly is due to me changing the SYS_STATUS message in MavLink, which means the original Mission Planner cannot decode it.

Is this the correct way to do it? I mean, changing the look of the SYS_STATUS message will make the original versions of Mission Planner, APM Planner 2 and MinimOSD unusable. Unless everyone agrees on the new message definition...

Of course I could create an entirely new MavLink message, but I really think the aux battery voltage belongs in the same place as the flight battery votage/current info.

Input please!

Surprised you have not gotten more input, I am interested and I know a lot of people are, but I lack any programming knowledge.  

If your "update" gets put as an official update, then I am sure other programs such as a MinimOSD will also have to update. Or some sort of if statement making sure the incoming is accepting the new message otherwise send legacy code. I hope you figure it out :)

Yes, I'm also surprised this thread is so quiet!

I reckon more than half the FPV-planes around uses a second battery for the video TX and camera, and of course everyone should want to monitor that battery. My current OSD has two voltage monitors, which saved me once when a bad video battery went from full to empty in about 30 seconds.

And my monologue continues! :)

I successfully compiled a new version of the Mission Planner software, which made it possible to set the voltage multiplier for the second battery, and turn monitoring on and off.

Now I just need to convince some more people to make changes in their code!

You got me.

I've been lurking around diy drones for nearly a year, but its this article that made me sign up so I could participate in what you have going on here.

I'm very interested in monitoring a second battery with my APM set up [arduplane]

However I am not very savy with the coding aspect of this. 

Could anyone assist me with implementing this? I would be very grateful.

Nice to see other people in this thread! :)

I have made all the changes needed in the ArduPlane and ArduCopter parts of ArduPilot. What has stopped me is MinimOSD, because I have not succeeded in making it understand the new MavLink message that includes battery_voltage_aux. I haven't managed to get any help either, as everyone else seems more interested in advanced functions than a basic one like this!

I have thought of letting this go and just buy a step-down converter and a filter to run the 12V stuff of the main battery, but a separate battery gives you some added redundancy (if you can monitor it) and minimizes the chance of noise in the video.

I'm also interested in capabilities for monitoring voltages from the ADCs, e.g. the voltage of a secondary battery. However, your implementation in your github repo breaks the MAVlink protocol by changing the SYS_STATUS message. The best way to put battery voltages on the MAVlink bus should be the BATTERY_STATUS message with different IDs, i.e. 0 for the main battery, 1 for the secondary etc. This will also require modifications to the minimOSD firmware - I'll maybe have some time soon to work on a patch

Reply to Discussion


© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service