$Id: battery-health,v 1.4 2021/11/29 17:58:22 nanons Exp $

Monitoring battery health
=========================

Battery information such as power usage and level of degradation can be
analyzed using OpenBSD's simple sysctl(2) hw.sensors subsystem.

"acpibat0" will be used as the example battery here.
To list attached batteries:

	$ dmesg | egrep "^(acpibat|acpisbs|owsbm|cwfg)[0-9]+ "

To list all of acpibat0's information:

	$ sysctl hw.sensors.acpibat0

Where:
* power0 is the current power usage, or charge rate if charging.
* watthour0 is the current maximum capacity, as of the last full charge.
* watthour4 is the maximum capacity when the battery was completely new.

To check the level of degradation, first charge the battery to 100% if
it wasn't fully charged in a long time, then compare how far off
watthour0 is from watthour4.  The missing capacity is degraded.

To show the overall status of all batteries:

	$ apm

Enable apmd(8) to log to /var/log/daemon whenever the battery charge
level changes substantially or the external power status changes:

	# rcctl enable apmd
	# rcctl start apmd

See also doc/performance and the apmd(8) man page.

Accuracy
========

Old ThinkPad BIOSes are known to have battery firmware bugs, causing
incorrect sensor reports.  Update to the latest BIOS with Lenovo's
OS-independent BIOS update bootable CD images, listed here:
https://download.lenovo.com/lenovo/content/ddfm/YOURMODEL.html
(where "YOURMODEL" is a ThinkPad model name such as "X200")

To burn the image to a CD:
* Blank the disc (if it is rewritable and already has contents).

	# cdio blank

* Write the image.

	# cdio tao /path/to/image.iso

