Simple cross-platform battery health checker for Windows, Linux, and macOS.
- Battery identifier (model/system battery id)
- Design capacity
- Full charge capacity
- Health percentage
- Optional values when available: current capacity, voltage, cycle count
- Python 3.8+ installed
- No third-party packages required
This project uses only Python's standard library.
- Open a terminal in this project folder:
path\to\battery_health - Confirm Python is installed:
python --version
- Run the script:
python battery_health.py
- (Optional) Create and activate a virtual environment:
python -m venv .venv .venv\Scripts\activate
Battery: <identifier>
Design Capacity: <value> mWh
Full Charge Capacity: <value> mWh
Health: <value>%
Current Capacity: <value> mWh
Voltage: <value> mV
Cycle Count: <value>
python -m unittest discover -s tests -p "test_*.py" -v- Windows:
- Uses
powercfg /batteryreportas the primary source. - Temporary report files are deleted automatically after parsing.
- Optionally enriches output with live battery fields from
Win32_Batterywhen Windows exposes them. - Falls back to
wmiconly on older systems where available.
- Uses
- Linux:
- Reads battery info from
/sys/class/power_supply/BAT*.
- Reads battery info from
- macOS:
- Reads battery info using
ioreg.
- Reads battery info using
No battery detected or unable to read battery information.:- Confirm the machine actually has a battery (desktops usually do not).
- On Windows, run
powercfg /batteryreportmanually to confirm battery data is available. - Make sure Python is running with permission to execute system battery commands.
pythonnot recognized:- Install Python from https://www.python.org/downloads/ and ensure "Add Python to PATH" is enabled.
- The script does not install anything or modify system settings.
- Any temporary files generated for report parsing are safely cleaned up.