Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Inspired by a blog post and the code that goes with it at jradavenport/batlog

To use the script, add a cron job to your crontab:

$ crontab -e

and enter this:

* * * * * /path/to/your/repo/ /path/to/log/file

What's Logged?

The data file contains the following values, tab separated:

  1. Timestamp, epoch format
  2. Current Capacity (Charge)
  3. Max Capacity (System Calculated Max Capacity)
  4. Pcnt of Max Capacity Remaining (% Charge)
  5. Cycle Count
  6. Max Capacity / Design Capacity (Battery Health)
  7. External Power Connected? (1/0)
  8. Charging? (1/0)
  9. Fully Charged? (1/0)
  10. Internal Battery Temp (C)
  11. Individual Cell Voltages (in mV)

What's the data look like?

1376806201	8292	8437	98.28	36	99.73	1	0	1	30.31	(4151,4151,4151,0)
1376806260	8292	8437	98.28	36	99.73	1	0	1	30.31	(4151,4151,4151,0)

How much space does the log take?

The entries in the sample above are 67 bytes. There are ~525,600 minutes in a year. That's about 35 MB per year. All entries might not be exactly 67 bytes and some years have an extra 1,440 minutes so the end of year total will vary a bit but it should be in that ball park.

Using the Data

A sample gnuplot script is included for creating graphs.

To create the graph, run the script:

/path/to/repo/ /path/to/log/file /path/to/graph.png

If your gnuplot isn't in cron's path, you can provide a custom path as the third argument:

/path/to/repo/ /path/to/log/file /path/to/graph.png /path/to/gnuplot

Here is a sample produced with it:

Sample Battery Graph


Log Apple Laptop Battery Data




No releases published
You can’t perform that action at this time.