# Battery Level not detected

## duckie

Hi,

Ive just put the battery monitor that comes with Gnome into the panel but it just says that there is no battery present and it doesnt change wether I have the mains supply plugged in or not.

I have tried a few different battery monitor apps just incase it was a software bug but they all had the same problem.

I expect that I havnt got an option in the kernel enabled.

Any Ideas how I can fix this?

Thanks in advance

----------

## Anior

Assuming that you're using a 2.6 kernel:

```
Power management options (ACPI, APM)  --->

    ACPI (Advanced Configuration and Power Interface) Support  --->

        Battery
```

You need to activate ACPI support for battery to show up.

Once you've compiled it in/insterted the module you should be able to see stats in /proc/acpi/battery/BAT1/ or /proc/acpi/battery/BAT0/ depending on your model.

Here's a bash script to show the status as well, rather minimal but usefull for promts and such:

```
#!/bin/bash

if [ -e /proc/acpi/battery/BAT0/ ]

        then

        path="/proc/acpi/battery/BAT0"

elif [ -e /proc/acpi/battery/BAT1/ ]

        then

        path="/proc/acpi/battery/BAT1"

else

        echo "No batteri found. Make sure that you have acpi support in your kernel."

        exit 1

fi

full=`cat $path/info|grep 'last full capacity'|awk -F: '{print $2}'|awk -Fm '{print $1}'`

current=`cat $path/state|grep 'remaining capacity'|awk -F: '{print $2}'|awk -Fm '{print $1}'`

state=$(( current * 100 / $full))
```

----------

## duckie

Anoir,

Thanks for youre reply,  I do have ACPI battey support activated in my kernel.

But I am a bit of a newbie and not to sure how I veiw the stats in /proc/acpi/battery/BAT1/  I opened the state file with nano and it just said  present     :no

Any other Ideas?

Thanks

----------

## Anior

That's really odd.

Looks like it detects a battery slot but nothing in it.

I would guess that support for your laptops ACPI implementation isn't fully working yet and that you need to wait for a newer kernel release.

I can get that result as well, if I actuall remove the battery.

Sorry for the stupid questions but just to be certain, you do have a laptop and the battery is connected, right?

----------

## duckie

lol yes i do have a laptop and it does have a battery  :Razz: 

new info tho

when trying to add the battery mon to my user accounts gnome panel  rather than root as i had done before  It displays this message

```
Can't access ACPI events in /var/run/acpid.socket! Make sure the ACPI subsystem is working and the acpid daemon is running.
```

----------

## Anior

The ACPI daemon is used to monitor and react to ACPI events, unfortunatly it won't help you detect your battery. :-(

Edit:

It can be started and stopped as any other service though:

sudo /usr/init.d/acpid start/stop/restart

sudo /sbin/rc-update add/del acpid (default)

----------

## reynolds531

What kind (make, model) laptop do you have? Some recent laptops (e.g., Acer) use so-called "Smart Batteries" that can't be monitored using older methods. Try doing a search on "smart battery" in this forum. There's a workaround that I haven't tried yet:

https://sourceforge.net/projects/sbs-linux/

----------

## duckie

I have a sony FR315S

I dont think it has a smart battery 

I  have since patched the kernel with the latest acpi driver   and also emerged  acpid and acpi  to no avail

do I need tp specify anything in a config for the acpi to work?

Im using a fairly fresh gentoo install that im just trying to iron the bugs out of

----------

## hypnotic

I'm having a similar problem.

Does it work if you start X as root? Mine does. It only fails when I start X using my non-root account. Maybe you are having the same permissions error I am. We probably need to add our non-root users to the wheel group or something. 

I'm still researching.

hypno

----------

## duckie

Okay now this is strange.

Just as an experiment I tried removing the battery to see if the status changed and when I put it back in the monitor detects it and its level.   

/proc/acpi  gives me the state and info of the battery  and the state of the AC-adapter  but the monitor tells me its on AC-power even when its not  yet the state file changes from on-line to off-line.

Any Ideas  coz im totally confused:?

Okay now it seems that if I enter X under battery power the monitor will show a battery icon  and then still show it if i plug in to AC, so It seems that the monitor is not updating to show AC status   or battery present before removing and re inserting the battery.

----------

## hypnotic

duckie,

I found this thread and it seems to solve my problem. I hope it helps you, too

https://forums.gentoo.org/viewtopic-t-241117-highlight-acpi+events+var+acpid+socket.html

I'm pretty much a newb, too so take the following with a grain of salt. It's more of an educated guess than true knowledge. But if you're at a total loss it might at least give you a direction to take.

If you aren't seeing useful information in /proc/acpi/battery/BAT0/info and /proc/acpi/battery/BAT0/state, it probably means your kernel can't even detect the battery. I think you'll have to get this working before any of the battery monitoring applets/desklets will work.

Also, there's something called I2C (and SMBus). It looks like these are used to interact with smart batteries. Maybe you just need to enable I2C and your I2C controller in your kernel. In my case, I had I2C enabled but not my specific controller and I was still able to see my battery status.

----------

## einstein1981

well I got mine working... 98 %, was just checking to see if anyone know how to have it update the icon when I plug in or out the ac jack...

I get percentaje readouts, and of course level changes in the batery drawing but, no change in the icon next, unless I restart acpid.

well thanks

charles

----------

## bgradid

 *einstein1981 wrote:*   

> well I got mine working... 98 %, was just checking to see if anyone know how to have it update the icon when I plug in or out the ac jack...
> 
> I get percentaje readouts, and of course level changes in the batery drawing but, no change in the icon next, unless I restart acpid.
> 
> well thanks
> ...

 

I have the same problem with a thinkpad 560z

----------

