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/logger.pl /path/to/log/file
The data file contains the following values, tab separated:
- Timestamp, epoch format
- Current Capacity (Charge)
- Max Capacity (System Calculated Max Capacity)
- Pcnt of Max Capacity Remaining (% Charge)
- Cycle Count
- Max Capacity / Design Capacity (Battery Health)
- External Power Connected? (1/0)
- Charging? (1/0)
- Fully Charged? (1/0)
- Internal Battery Temp (C)
- Individual Cell Voltages (in mV)
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)
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.
A sample gnuplot script is included for creating graphs.
To create the graph, run the plot.sh script:
/path/to/repo/plot.sh /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/plot.sh /path/to/log/file /path/to/graph.png /path/to/gnuplot
Here is a sample produced with it: