{"id":22814705,"url":"https://github.com/antoninpvr/battery-logger","last_synced_at":"2026-05-17T11:35:25.890Z","repository":{"id":266755537,"uuid":"899259473","full_name":"AntoninPvr/battery-logger","owner":"AntoninPvr","description":"Simple scripts to record data from my laptop battery","archived":false,"fork":false,"pushed_at":"2024-12-09T18:00:34.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-25T07:49:27.056Z","etag":null,"topics":["bash-script","battery","data"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AntoninPvr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-12-05T22:58:18.000Z","updated_at":"2024-12-09T18:00:37.000Z","dependencies_parsed_at":"2024-12-06T00:23:24.998Z","dependency_job_id":"f77014af-6caa-409e-8412-70f1cd350c9e","html_url":"https://github.com/AntoninPvr/battery-logger","commit_stats":null,"previous_names":["antoninpvr/battery-logger"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/AntoninPvr/battery-logger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntoninPvr%2Fbattery-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntoninPvr%2Fbattery-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntoninPvr%2Fbattery-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntoninPvr%2Fbattery-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AntoninPvr","download_url":"https://codeload.github.com/AntoninPvr/battery-logger/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntoninPvr%2Fbattery-logger/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33136902,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T09:28:26.183Z","status":"ssl_error","status_checked_at":"2026-05-17T09:27:52.702Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash-script","battery","data"],"created_at":"2024-12-12T13:09:45.093Z","updated_at":"2026-05-17T11:35:25.870Z","avatar_url":"https://github.com/AntoninPvr.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Battery Logger Script\n\n## Objective\n\nThis script was designed to log battery information from a system, originally for the **Razer Blade 15 Advanced (2020)** but it can support almost all laptops or battery powered linux systems. It provides periodic logging of battery parameters such as current, voltage, capacity, charge, temperature, and charging status. The script is flexible, allowing you to specify logging intervals, battery paths, output files, and maximum runtime. Additionally, it includes an optional terminal interface to display live data and log size.\n\n## Features\n- Logs battery data to a CSV file.\n- Allows specification of output file and interval.\n- Option to specify a custom battery path.\n- Maximum runtime option (runs indefinitely by default).\n- Display a real-time terminal interface with battery data.\n- Supports both command-line arguments and help options.\n\n## Prerequisites\n- Linux system with `/sys/class/power_supply/` for battery information.\n- `acpi` command installed (for temperature reading, optional).\n- Bash shell.\n\n---\n\n## Installation\n\n```bash\nchmod +x battery_logger.sh\n```\n\n## Usage\n\n```bash\n./battery_logger.sh [OPTIONS]\n```\n### Options:\n\n- `-o, --output \u003cFILE\u003e`  \n  Specify the output CSV file where the battery data will be logged (default: `battery_log.csv`).\n\n- `-i, --interval \u003cSECONDS\u003e`  \n  Specify the logging interval in seconds (default: `60`).\n\n- `-b, --battery \u003cBATTERY_PATH\u003e`  \n  Specify the path to the battery information (default: autodetected as `/sys/class/power_supply/BAT*` and take the first occurence). \n\n- `-t, --time \u003cSECONDS\u003e`  \n  Specify the maximum runtime of the script in seconds. If set to `0`, the script runs indefinitely.\n\n- `--no-interface`  \n  Disable the terminal interface that displays real-time battery data (default: enabled).\n\n- `-h, --help`  \n  Display the help message.\n\nTo exit the script, press `Ctrl+C`.\n\n### Example:\n    \n- To log **first battery** data every **30 seconds** to a file named `battery_0_log.csv` indefinitely:\n\n    ```bash\n    ./battery_logger.sh -o battery_0_log.csv -i 30\n    ```\n\n- To log **second battery** data every **2 seconds** to a file named `my_battery_log.csv` for 1 hour:\n\n    ```bash\n    ./battery_logger.sh -o my_battery_log.csv -i 2 -b /sys/class/power_supply/BAT1 -t 3600\n    ```\n\n### Terminal Interface:\n\nThe terminal interface displays real-time battery data and log file size. It is enabled by default and can be disabled using the `--no-interface` option.\n\n```\n====================== BATTERY LOGGER =====================\nInterval: 10 seconds\nBattery Path: /sys/class/power_supply/BAT0\nStart Time: Fri Dec  6 07:31:27 PM EST 2024\n===========================================================\nLog File: battery_log.csv\nCurrent Log File Size: 4.0K\n\n=================== Current Battery Data ==================\n| Metric         | Value (converted)  | Raw Value         |\n|----------------|--------------------|-------------------|\n| current_now    | 1089.000 mA        | 1089000           |\n| charge_now     | 4073.000 mAh       | 4073000           |\n| voltage_now    | 16.071 V           | 16071000          |\n| capacity       | 75 %                                   |\n===========================================================\ntemperature      : 27.8 °C\ncharging status  : Discharging\n===========================================================\nProgress: |###########                      | ETA: 01:36:21\n```\n\n## Notes\n\n- **current_now** : Current in microamperes.\n    some systems may report only positive values. In this case, charging status can be used to determine the direction of the current.\n- **charge_now** : Charge in microampere-hours.\n- **capacity** : Battery capacity in percentage.\n- **voltage_now** : Voltage in microvolts.\n- **temperature** : Battery temperature in Celsius.\n- **charging status** :\n\n  | Status | Value |\n  |---|---|\n  | Charging | 1 |\n  | Discharging | -1 |\n  | Full | 0 |\n  | Unknown | 0 |\n\n## Known Issues\n\n- Battery temperature : on some system battery temperature is always 27.8°C.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantoninpvr%2Fbattery-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantoninpvr%2Fbattery-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantoninpvr%2Fbattery-logger/lists"}