Skip to content

Python SL4A module to limit Android battery charging via Wifi smart switch

License

Notifications You must be signed in to change notification settings

bjamesv/pyAndChargeLimit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

pyAndChargeLimit calls a REST API when your Android mobile device reaches a user defined battery percentage. This enables optimized, "40-80" battery charging of unrooted, unattended devices using free, open-source software.

Charge shutoff requires:

  • An external hardware IoT smart switch, with Wifi interface and REST API (such as a inexpensive 'DIY Mode' Sonoff device or smartplug running Tasmoda)
  • QPython
  • Root is not required

Example:

Setup

  • Install QPython, tap QPYPI > QPYPI CLIENT, run pip install requests PyYAML watchdog
  • Copy stopcharge.py to QPython scripts/ directory
  • Copy config.yml to QPython scripts/ directory

Setting up the hardware smart switch to connect to the Android device's Wifi hotspot or wifi network is beyond the scope of this README. (See: Protocol Doc for Sonoff DIY Mode, etc.)

Usage

To run pyAndChargeLimit

  • Edit config.yml off-device, or with an Android YAML editor of your choice (per Issue #1).
    • Enter the Sonoff deviceId & IP address of the smart outlet your charger is plugged into
    • Copy config.yml to QPython scripts/ directory on your Android device
  • On your Android device, open QPython, tap Explorer > scripts/ > stopcharge.py
  • Tap the ▶️ icon, tap ⬅️ icon near top of terminal screen (see Example above), tap YES at the prompt for Run on background

Charge limit is set at 80%, to minimize degradation of lithium-ion battery capacity.

Background

Lithium-ion battery capacity can be conserved by minimizing recharge time while the battery state of charge (SoC) is low (<30-40%) or very high (>80%). "How to prolong " (Cadex Electronics Inc.)

Stock Android 10 can easily set a Battery Saver minimum percentage, but unattended charging cannot be stopped at a specified maximum percentage without rooting.

Google Pixel 3a XL seems to try and lessen capacity degredation, by reducing charging rate when battery is below 40% and significantly reducing rate above 80% charged.


Per Alex Walker-Todd, 2019 (trustedreviews.com)

PyAndChargeLimit lets unrooted, unattended devices further reduce capacity degradation by eliminating all charging / discharging above a specified SoC.

About

Python SL4A module to limit Android battery charging via Wifi smart switch

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages