Skip to content

DarishDias/BatteryBackupLogger-Windows11

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Battery Backup Monitor for Windows 11

This script monitors your laptop's battery usage and tracks how long the battery lasts on a single charge, with smart pause/resume functionality.

Features

  • Smart Timer: Starts when unplugged at 97%+ battery
  • Intelligent Pause/Resume: Pauses when charging, resumes only after draining to previous percentage
  • Auto-Reset: Resets timer when charging above 90%
  • Notifications: Windows toast notifications with sound alerts
  • Data Logging: Saves battery backup records to CSV file
  • Average Calculation: Tracks average battery backup duration

Files

  • BatteryMonitor.ps1 - Main monitoring script
  • RunBatteryMonitor.bat - Batch file to run the script
  • SetupAutoStart.ps1 - Sets up automatic startup
  • TestBatteryMonitor.ps1 - Tests all functions
  • README.md - This file

Setup Instructions

1. Test the Script First

# Right-click on TestBatteryMonitor.ps1 and "Run with PowerShell"
# This will verify everything is working

2. Set Up Auto-Start (Recommended)

# Right-click on SetupAutoStart.ps1 and "Run as Administrator"
# This creates a Windows Task that runs on every login

3. Manual Testing

# To test manually, right-click on BatteryMonitor.ps1 and "Run with PowerShell"
# Or double-click RunBatteryMonitor.bat

How It Works

  1. Start: Unplug charger at 97%+ battery → Timer starts
  2. Pause: Plug in between 20-89% → Timer pauses
  3. Resume: Unplug again → Timer waits until battery drains to previous percentage
  4. Reset: Charge above 90% → Timer resets completely
  5. Complete: Connect charger below 10% → Saves recording

Configuration

The script uses these thresholds (you can modify in the script):

  • Full Battery: 97% (triggers timer start)
  • Low Battery: 10% (saves recording)
  • Pause Range: 20-89% (timer pauses when charging)
  • Reset Threshold: 90% (timer resets when charging above this)
  • Disconnect Notification: 90% (reminds you to unplug)

Log Files

All data is saved to: Documents\BatteryBackup\

  • battery_backup_records.csv - Individual backup sessions
  • battery_backup_average.txt - Average backup duration

Troubleshooting

If notifications don't work:

  • Check Windows notification settings
  • Ensure "Focus Assist" is not blocking notifications

If script won't run:

  • Check PowerShell execution policy: Get-ExecutionPolicy
  • If restricted, run: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

If auto-start doesn't work:

  • Run SetupAutoStart.ps1 as Administrator
  • Check Task Scheduler: taskschd.msc
  • Look for "BatteryMonitor" task

Verification

To verify it's working:

  1. Check Task Manager: Look for PowerShell processes
  2. Check Logs: Look for files in Documents\BatteryBackup\
  3. Check Notifications: You should see notifications when conditions are met
  4. Check Console: If running manually, you'll see real-time status

Support

If you encounter issues:

  1. Run TestBatteryMonitor.ps1 first
  2. Check the console output for error messages
  3. Verify all files are in the correct location
  4. Ensure PowerShell execution policy allows script execution

About

This script monitors your laptop's battery usage and tracks how long the battery lasts on a single charge, with smart pause/resume functionality.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors