{"id":2507,"date":"2010-05-27T20:37:02","date_gmt":"2010-05-28T03:37:02","guid":{"rendered":"http:\/\/multimedia.cx\/eggs\/?p=2507"},"modified":"2020-07-25T22:10:05","modified_gmt":"2020-07-26T05:10:05","slug":"monster-battery-power-revisited","status":"publish","type":"post","link":"https:\/\/multimedia.cx\/eggs\/monster-battery-power-revisited\/","title":{"rendered":"Monster Battery Power Revisited"},"content":{"rendered":"<p>So I have this <a href=\"http:\/\/multimedia.cx\/eggs\/monster-netbook-battery\/\">new fat netbook battery and I performed an experiment<\/a> to determine how long it really lasts. In my last post on the matter, it was suggested that I should <a href=\"http:\/\/multimedia.cx\/eggs\/monster-netbook-battery\/#comment-151680\">rely on the information that gnome-power-manager<\/a> is giving me. However, I have rarely seen GPM report more than about 2 hours of charge; even on a full battery, it only reports 3h25m when I profiled it as lasting over 5 hours in my typical use. So I started digging to understand how GPM gets its numbers and determine if, perhaps, it&#8217;s not getting accurate data from the system.<\/p>\n<p>I started poking around \/proc for the data I wanted. You can learn a lot in \/proc as long as you know the right question to ask. I had to remember what the power subsystem is called &#8212; ACPI &#8212; and this led me to \/proc\/acpi\/battery\/BAT0\/state which has data such as:<\/p>\n<pre>\r\npresent:                 yes\r\ncapacity state:          ok\r\ncharging state:          charged\r\npresent rate:            unknown\r\nremaining capacity:      100 mAh\r\npresent voltage:         8326 mV\r\n<\/pre>\n<p>&#8220;Remaining capacity&#8221; rated in mAh is a little odd; I would later determine that this should actually be expressed as a percentage (i.e., 100% charge at the time of this reading). Examining the GPM source code, it seems to determine as a function of the current CPU load (queried via \/proc\/stat) and the battery state queried via a facility called devicekit. I couldn&#8217;t immediately find any source code to the latter but I was able to install a utility called &#8216;devkit-power&#8217;. Mostly, it appears to rehash data already found in the above \/proc file.<\/p>\n<p>Curiously, the file \/proc\/acpi\/battery\/BAT0\/info, which displays essential information about the battery, reports the design capacity of my battery as only 4400 mAh which is true for the original battery; the new monster battery is supposed to be 10400 mAh. I can imagine that all of these data points could be conspiring to under-report my remaining battery life.<\/p>\n<p><strong>Science project:<\/strong> <a href=\"http:\/\/multimedia.cx\/eggs\/monster-netbook-battery\/\">Repeat the previous power-related science project<\/a> but also parse and track the remaining capacity and present voltage fields from the battery state proc file.<\/p>\n<p>Let&#8217;s skip straight to the results (which are consistent with my last set of results in terms of longevity):<\/p>\n<p><center><br \/>\n<img decoding=\"async\" src=\"http:\/\/spreadsheets0.google.com\/oimg?key=0AjHexWy1UYqidHk3OXBCeXQ4cFQ0RGI5RHBZRGMzX2c&#038;oid=2&#038;zx=7gt5w9-e8bzjt\" \/><br \/>\n<\/center><\/p>\n<p>So there is definitely something strange going on with the reporting&#8211; the 4400 mAh battery reports discharge at a linear rate while the 10400 mAh battery reports precipitous dropoff after 60%. <\/p>\n<p>Another curious item is that my script broke at first when there was 20% power remaining which, as you can imagine, is a really annoying time to discover such a bug. At that point, the &#8220;time to empty&#8221; reported by devkit-power jumped from 0 seconds to 20 hours (the first state change observed for that field).<\/p>\n<p>Here&#8217;s my script, this time elevated from Bash script to Python. It requires <a href=\"http:\/\/www.semicomplete.com\/projects\/xdotool\/\">xdotool<\/a> and devkit-power to be installed (both should be available in the package manager for a distro).<br \/>\n<!--more--><\/p>\n<p><script src=\"https:\/\/gist.github.com\/multimediamike\/402d677b12dac4f6900ca9bf39a6eb70.js\"><\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Who&#8217;s giving me weird battery data?<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[55,218],"tags":[],"class_list":["post-2507","post","type-post","status-publish","format-standard","hentry","category-python","category-science-projects"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts\/2507","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/comments?post=2507"}],"version-history":[{"count":7,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts\/2507\/revisions"}],"predecessor-version":[{"id":4577,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts\/2507\/revisions\/4577"}],"wp:attachment":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/media?parent=2507"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/categories?post=2507"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/tags?post=2507"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}