Auto-update battery percentage by sending pseudo current sensor output to Cube

Updating the battery percentage based on voltage in flight is difficult if not impossible, but would it be possible to update the capacity automatically before the flight by having the cube read consumed mah? Is there any sort of scripting available that can hijack the current sensor BATT_1 telemetry to subtract the estimated current from the battery voltage prior to arming and update the percentage without actually sending the current through the current sensor?

For example, Battery is plugged in (in our case, 25000mah 6s)
Voltage is read as 24.14v
6s 100% charge is 25.2
6s 0% is set as 22.12 (actually 10% battery voltage)
Range of 3.08v from (0%-100%)
Battery percentage is calculated as 65%
65% of 25000mah is 16250mah
Cube Orange reads the 16250mah as spent.

This could also maybe be a raspberry pi plugged into the BATT_2 port that reads the voltage and spits out the amount estimated to have been consumed by playing as if it is a current sensor. Maybe? Kind of just brainstorming here.

Basically, condensing my question into one sentence:
Does the 16250mah need to physically pass through the hall sensor to be marked as spent, or is there a script that can just tell the cube that 16250mah has been spent so that the percentage updates immediately?

Probably not super clear, but I’d love some help solving this problem

You are over simplifying the problem. The discharge curves of LiPo batteries are highly non-linear. We will get invalid results when interpolating charge based on the resting voltage.
What you want is called SOC (State-of-charge) calculation and there are many PhD Thesis on the topic, because it is a very complex one.

So, no, there is no way of correctly setting the value you want. You need to always provide a fully charged Akku at the beginning of the flight and then everything will work as expected.

1 Like

How does the battery percentage work at the moment? Is it simply a linear calculation of cell voltage? Or is it based on mah consumed?

Of course this. You can’t predict pack consumption from voltage level. If current isn’t being measured you don’t get battery percentage.

Uh oh, only flown for 30s and I’m down to ~50% “capacity”:

Ok, that makes sense. So every time you power up the flight controller it begins at 100% regardless of the actual state of charge, and a parameter of battery capacity sets the scaling for battery % remaining.
So for the original poster, he could just modify the akku capacity parameter to whatever his “best guess” is given the no load voltage observed. Or just fully charge the battery and use the rated mah number as you suggested.

1 Like

Yes, @Scott_Nunan that is correct

Yeah it sounds like this will be the best bet for now. I’m not looking for an exact number, just an estimate that shows “Hey, this battery does NOT have a full charge” when you plug it in.

There is a BAT_ARM_VOLT parameter if that does the job. That will produce “Hey, this craft won’t arm because the battery isn’t fully charged” :slight_smile:

1 Like

perfect! sounds like I can set this for a voltage that would match ~60% or so.

1 Like

There is also a BAT_ARM_MAH parameter but only good with Smart battery functions for the reasons we have been discussing.

Do the discharge curves vary from battery to battery, or does each battery follow a similar discharge curve? Also, I use a “Cell checker” that plugs into the balance port of the lipo prior to placing a load on the battery. Is this inaccurate, and also, what is the margin of error using this method?

Temperature and current draw will effect the signature of the discharge curve also.

I don’t know anything about these or if they are even available. Smart Monitor
Looks like a BAB (big ass board) for what it does.


Thanks for linking this, I’ll check it out. Our VTOL is fairly large so it should be able to take a BAB, and the weight gain might be worth seeing an accurate percentage.

Varies from battery to battery. And the same battery varies with temperature, age, and charge level cycling.

Yes it is inaccurate, but there is no simple and correct alternative.

The best alternative are smart batteries. But their software must be really good. There are some “not-so-smart” batteries out there.

Please read more on the topic.