Last active
June 12, 2019 05:21
-
-
Save egecelikci/14c0bf889163cfa77cdddd227b0e943c to your computer and use it in GitHub Desktop.
A shell script designed to keep battery log on Android devices
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CAPACITYVOLTAGE=0 | |
| INTERVAL=1 | |
| while true; do | |
| PREVVOLTAGE=$CAPACITYVOLTAGE | |
| DATETIME=$(date +'%Y/%m/%d|%H:%M:%S') | |
| CAPACITYVOLTAGE="$(( $(cat /sys/class/power_supply/battery/voltage_now) / 1000 ))" | |
| CAPACITYPERCENT="$(cat /sys/class/power_supply/battery/capacity)" | |
| DISCHARGE="+$(( $CAPACITYVOLTAGE - $PREVVOLTAGE ))" | |
| TEMP="$(( $(cat /sys/class/power_supply/battery/temp) / 10))" | |
| echo "${DATETIME} | ${CAPACITYPERCENT}% | $(echo ${DISCHARGE}|sed -e 's/^+-/-/')mA | ${CAPACITYVOLTAGE}mV | ${TEMP}°C"; | |
| sleep $INTERVAL; | |
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 2019/06/12|08:19:48 | 25% | +0mA | 3948mV | 38°C | |
| 2019/06/12|08:19:49 | 25% | +6mA | 3954mV | 38°C | |
| 2019/06/12|08:19:50 | 25% | +0mA | 3954mV | 39°C | |
| 2019/06/12|08:19:51 | 25% | -1mA | 3953mV | 39°C | |
| 2019/06/12|08:19:53 | 25% | +0mA | 3953mV | 39°C | |
| 2019/06/12|08:19:54 | 25% | +0mA | 3953mV | 39°C | |
| 2019/06/12|08:19:55 | 25% | +3mA | 3956mV | 39°C | |
| 2019/06/12|08:19:56 | 25% | +0mA | 3956mV | 39°C | |
| 2019/06/12|08:19:58 | 25% | -1mA | 3955mV | 39°C | |
| 2019/06/12|08:19:59 | 25% | +0mA | 3955mV | 39°C | |
| 2019/06/12|08:20:00 | 25% | -2mA | 3953mV | 38°C | |
| 2019/06/12|08:20:01 | 25% | +0mA | 3953mV | 38°C |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment