maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Nokia N900 (https://talk.maemo.org/forumdisplay.php?f=44)
-   -   Guide to get detailed battery information (https://talk.maemo.org/showthread.php?t=36613)

Phantasm 2009-12-10 18:49

Guide to get detailed battery information
 
N900 allows one to check full detailed information about the battery.

The basic way to get everything is to open the X terminal and type "lshal|grep bat". There is also another way to get the information, but the output isn't well sorted. It is "hal-device bme" which is executed much faster and as such is used in the aliases later on.

Note. The commands don't show anything useful while charging.

You will get following output (numbers on front of lines have been added for easier explaining):
Code:

~ $ lshal|grep bat
1  battery.charge_level.capacity_state = 'ok'  (string)
2  battery.charge_level.current = 2  (0x2)  (int)
3  battery.charge_level.design = 8  (0x8)  (int)
4  battery.charge_level.last_full = 0  (0x0)  (int)
5  battery.charge_level.percentage = 12  (0xc)  (int)
6  battery.charge_level.unit = 'bars'  (string)
7  battery.is_rechargeable = true  (bool)
8  battery.present = true  (bool)
9  battery.rechargeable.is_charging = false  (bool)
10  battery.rechargeable.is_discharging = true  (bool)
11  battery.remaining_time = 0  (0x0)  (int)
12  battery.remaining_time.calculate_per_time = false  (bool)
13  battery.reporting.current = 160  (0xa0)  (int)
14  battery.reporting.design = 1248  (0x4e0)  (int)
15  battery.reporting.last_full = 0  (0x0)  (int)
16  battery.reporting.unit = 'mAh'  (string)
17  battery.type = 'pda'  (string)
18  battery.voltage.current = 3753  (0xea9)  (int)
19  battery.voltage.design = 4200  (0x1068)  (int)
20  battery.voltage.unit = 'mV'  (string)
21  info.capabilities = {'battery'} (string list)
22  info.category = 'battery'  (string)

1. Shows "full" at 8 bars. Possibly still full at 7 bars. "Low" at 1 bars or something and elsewhere "ok". Quite useless.
2. Remaining battery life in bars (number representation of the battery bar shown on top left of the screen just right of programs button).
3. Bar value of full charged new battery.
4. Bar value the battery had last time it was fully charged. Typically 8 for quite new battery. Seems to reset to 0 in a few minutes after taking off the charger.
5. Percentage of battery charge remaining. This is the most useful value for most users.
6-10. Self explanatory.
11. Very inaccurate time remaining on battery charge at current usage. Supposed to be in seconds (I recall reading that from somewhere) but is far from reality and updates very rarely.
12. Not sure what this should mean. Always shows false for me.
13. Current remaining battery charge in mAh.
14. Capacity of the current battery when it was manufactured.
15. Full charge mAh value from last full charge. Seems to reset to 0 in a few minutes after taking off the charger.
16-17. Self explanatory.
18. Current battery voltage. Depends on recent usage level and battery charge level. Only useful for advanced users.
19. Voltage of the battery when fully charged. The value is for when manufactured, but this does not change for old batteries.
20. Self explanatory
21-22. Useless.

So, all in all, the lines 5, 13, 14 and 18 are of more use. And the line 14 can be easily remembered approximately and as such is generally useless in long term.

The only useful value shown while charging, is the line 18 (voltage). After getting used to the voltage behavior of rechargeable Li-Ion battery, you can approximate the remaining charge time from the voltage value.

Here are some aliases premade for various people to ease the life. They are put into a file ".profile" in the home directory (the directory X terminal puts you on at start). A quick newbie quite for how to use vi (the only editor I found on the X terminal). Start editing the file with "vi .profile". Type "a" to enter editing mode. Edit the file normally (do not press anything strange such as keys with CTRL or ESC etc). If something strange happens, close the X terminal and start from beginning. Once ready, click ESC, type ":write" and type ":q". To get "|" symbol, use secondary function of CTRL-key on the keyboard.

Aliases work as such that the word before "=" does the command between parenthesis. You can easily customize the aliases to be done with other commands. Eg. following 2 aliases do same thing, except first is executed with foo and second with bar.
alias foo="echo test"
alias bar="echo test"

Some basic aliases to simplify the rest of the aliases. Grep is a command used to look for given pattern from the lines. Matching lines are left remaining. With -v parameter the behavior is reverse, thus only lines not matching are left remaining.
alias lg="hal-device bme|grep"
alias g="grep"
alias gv="grep -v"

Alias suited for most users showing only line 5 (charge percentage):
alias b="lg erc"
(or alias b="hal-device bme|grep erc" )

Alias giving a bit more info for more advanced users and for battery usage testing. Shows lines 5, 13 and 18 (charge percentage, mAh remaining and voltage):
alias ba="lg erc;lg rr|gv h"

Alias for same as above except with line 14 (design charge in mAh) as well:
alias bat="lg erc;lg g.des;lg rr|gv h"

Alias for generally everything at least somewhat useful (lines 1-5, 13-15 and 18-19):
alias battery="lg bat|gv nf|gv pr|gv yp|gv un|gv is|gv lc|gv im"

As for advanced info about how charge remaining in mAh and voltage vary depending on power usage. Voltage tends to drop somewhat below the normal level when you do something intensive. More than when the charge is lower. The remaining charge shouldn't raise, but it seems the logic used in determining battery charge is a bit simplified, and as such there are some differences there. After a period of intensive usage, the charge remaining may actually raise around 10-20 mAh while the device is at idle for 5-20 minutes. It is crucial to experiment around with this a bit for more accurate results on battery usage tests.


In case you have something to add (or perhaps found an error), feel free to comment. I will be updating this post to match latest information and answering all possible questions people might have.

msa 2009-12-10 19:31

Re: Guide to get detailed battery information
 
um... thanks?

is it possible to make a script or something like that which only outputs specific values?

(and then, consequently, create some kind of shortcut for the desktio so you can just click/push on it and get all intersting information for you output on the screen)

Phantasm 2009-12-10 19:41

Re: Guide to get detailed battery information
 
Quote:

Originally Posted by msa (Post 421416)
um... thanks?

is it possible to make a script or something like that which only outputs specific values?

(and then, consequently, create some kind of shortcut for the desktio so you can just click/push on it and get all intersting information for you output on the screen)

For the script, sure. Go ahead and experiment with grepping on the X terminal. Not sure about making such shortcut.

412b 2009-12-10 23:39

Re: Guide to get detailed battery information
 
A small hint: "hal-device" will give you the output much faster. As I still have no n900 I can propose "hal-device bme" ;)

Phantasm 2009-12-11 00:02

Re: Guide to get detailed battery information
 
Quote:

Originally Posted by 412b (Post 421853)
A small hint: "hal-device" will give you the output much faster. As I still have no n900 I can propose "hal-device bme" ;)

Ah yes. Seems to work just fine and is much faster, thanks. Though, the output isn't organized as well. Will update the first post accordingly.

adrianp 2009-12-11 13:16

Re: Guide to get detailed battery information
 
Quote:

Originally Posted by Phantasm (Post 421349)
Alias for same as above except with line 14 (design charge in mAh) as well:
alias bat="lg erc;lg g.des;lg rr|gv h;

Thanks for this - one tiny thing, missing " from end of this alias.

Phantasm 2009-12-11 15:27

Re: Guide to get detailed battery information
 
Quote:

Originally Posted by adrianp (Post 422717)
Thanks for this - one tiny thing, missing " from end of this alias.

Ops. Fixed and thanks for pointing it out. :)

M289 2009-12-11 16:37

Re: Guide to get detailed battery information
 
Wouldn't it be possible to create a widget with detailed battery info?

I have to admit I have yet to take a look at the sdk/docs etc. :)

Phantasm 2009-12-11 17:15

Re: Guide to get detailed battery information
 
Quote:

Originally Posted by M289 (Post 423096)
Wouldn't it be possible to create a widget with detailed battery info?

I have to admit I have yet to take a look at the sdk/docs etc. :)

I'm sure it is. Just takes some random Maemo coder 15 minutes or so prolly.

Would be neat to have a widget that replaces the normal battery bar with battery charge percentage number.

412b 2009-12-17 19:41

Re: Guide to get detailed battery information
 
Quote:

Originally Posted by Phantasm (Post 423166)
I'm sure it is. Just takes some random Maemo coder 15 minutes or so prolly.

LOL
Quote:

Originally Posted by Phantasm (Post 423166)
Would be neat to have a widget that replaces the normal battery bar with battery charge percentage number.

There is, but not for Maemo 5 at the moment ;) Porting is in progress ;)


All times are GMT. The time now is 17:44.

vBulletin® Version 3.8.8