Question

There is some easily available information on finding the status of a battery, or weather it's charging or not. (GetSystemPowerStatus API or System.Windows.Forms.SystemInformation.PowerStatus).

I want to be able to stop a battery from charging based on some criteria, e.g. battery power > 20%.

Is there an API to do this?

Was it helpful?

Solution

I think it's impossible, because you have need some API for battery or battery charger.

And this API can provide to you manufacturer of notebook and battery or battery charger support this.

OTHER TIPS

I honestly don't know, but I'd have a look at the APM or ACPI APIs.

Other than that, the only option I can think of right now is a USB controlled robotic arm that ejects the battery when you need to stop charging, but that's probably not what you are looking for, and borders on the complicator's glove in terms of level of over-engineering. :)

I think it's possible, because it was patented by IBM (patent no. 7570015).

Not sure if there's a Windows API available for that.

One of the options is to get hold of the device(I) for battery (Microsoft ACPI-Compliant Control Method Battery). Listen for PowerNotification events forever. On each notification check the PowerStatus of the battery. There are APIs for all of the above purposes in .Net and win32

Keep the device(I) disabled as long as the powerstatus is >threshold. Enable it as soon as goes below that or when you are not on AC power (i.e. before removing AC power, your continuously monitoring software should enable that battery device - or you manually enable it).

hmm,...this is a very buggy solution, but it can achieve what you want, although you have to be very careful.

I would just get a UPS and programatically tell it to cut all power... most should have an interface for doing this. Otherwise, as someone already said - a computer-controlled power strip would do it ^^

I've actually played with this idea when I was testing/writing about way too many new laptop models a while ago and the battery testing was annoying to set up, monitor and analyze.

I wrote an app that would do exactly everything (setup, listening, measuring, reporting) except unplugging the power and then replugging it and starting the computer again...

I think MiCTech is right. I dont think it is possible but here are some resources which you might useful.

But for example Vista won't charge battery if it is unplugged and then plugged while it's capacity is above 96% so it means that in can be accessed and manipulated somehow.

Lenovo laptops know lets you specify the charging levels from bios or from their software, but this feature must be implemented in bios in order to be accessed from windows.

I came to conclusion:

just give up and forget this matter. It is not a problem, so dont worry about that. Let it be plugged in and be fully charged. when it is on 100%, then the system automatically stops charging, and goes on the plug power, so, maybe no worry to wear a battery, as all notebooks (if it's not from the XX century) has auto regulation of it. Although, If you will ever need, move you hands and plug it on/off manually. Dont be lazy. That is the #1 and quickest solution, beleive me.

(however, if you want to waste time, here are methods -
1) http://www.makeuseof.com/answers/what-battery-manager-can-stop-charging-at-a-certain-percentage/
2) disable devices temporarily (But you need to disable "Microsoft ACPI-Compliant Control Method Battery")
3) https://superuser.com/questions/813182/how-to-stopdisable-battery-charging-on-laptop

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top