{"id":12753,"date":"2010-09-24T07:00:00","date_gmt":"2010-09-24T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2010\/09\/24\/how-reliable-is-the-batterylifepercent-member-of-the-system_power_status-structure\/"},"modified":"2010-09-24T07:00:00","modified_gmt":"2010-09-24T07:00:00","slug":"how-reliable-is-the-batterylifepercent-member-of-the-system_power_status-structure","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20100924-00\/?p=12753","title":{"rendered":"How reliable is the BatteryLifePercent member of the SYSTEM_POWER_STATUS structure?"},"content":{"rendered":"<p>A customer was writing a program that called <code>Get&shy;System&shy;Power&shy;Status<\/code> and used the <code>SYSTEM_POWER_STATUS.Battery&shy;Life&shy;Percent<\/code> value. The customer wanted to know whether a reported battery life percentage of 38% really means that the remaining battery life is between 37.5% and 38.5%.\n Although the value is reported to 1% <a href=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2005\/09\/02\/459952.aspx\"> precision<\/a>, the accuracy in practice is much worse. Similarly, the <code>Battery&shy;Life&shy;Time<\/code> is reported in seconds, but if your battery actually lasts exactly the amount of time predicted by that field (and not a second longer or shorter), it&#8217;s almost certainly a fluke. Even a stopped clock is right twice a day.\n These battery levels come from the hardware itself, so you are at the mercy of whoever manufactured your motherboard. Some laptops update the values at 1-second intervals; others can take 5&nbsp;seconds or more. In practice, these hardware-reported values have been found not to be particularly precise, and in odd cases have occasionally been spotted behaving in strange ways, such as spiking briefly and then returning to a sane value.\n But if you use the values (as flaky as they might be), you&#8217;ll at least be in good company: These are the same values that the Windows Battery Meter displays.<\/p>\n<p> <b>Bonus chatter<\/b>: There&#8217;s another interface for retrieving battery life information, and that&#8217;s WMI <code>Win32_Battery.Estimated&shy;Run&shy;Time<\/code>. The values for this also come from the hardware, but they are more unstable than the values returned by <code>Get&shy;System&shy;Power&shy;Status<\/code> because the estimated run time is an extrapolation based on the current battery load. This makes it more sensitive to short-term fluctuations in energy consumption, creating the paradoxical situation where more accurate information is actually less useful. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>A customer was writing a program that called Get&shy;System&shy;Power&shy;Status and used the SYSTEM_POWER_STATUS.Battery&shy;Life&shy;Percent value. The customer wanted to know whether a reported battery life percentage of 38% really means that the remaining battery life is between 37.5% and 38.5%. Although the value is reported to 1% precision, the accuracy in practice is much worse. Similarly, [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-12753","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>A customer was writing a program that called Get&shy;System&shy;Power&shy;Status and used the SYSTEM_POWER_STATUS.Battery&shy;Life&shy;Percent value. The customer wanted to know whether a reported battery life percentage of 38% really means that the remaining battery life is between 37.5% and 38.5%. Although the value is reported to 1% precision, the accuracy in practice is much worse. Similarly, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/12753","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=12753"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/12753\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=12753"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=12753"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=12753"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}