A utility to calculate battery charging speeds, efficiency, and verify USB-PD charging profiles compatibility.
Project description
CairoVolt Charge Calc
A lightweight Python library to calculate battery charging dynamics, watt-hours (Wh), effective power bank output capacities at different discharge voltages, and to diagnose USB-PD (Power Delivery) profile compatibility.
This package was developed for CairoVolt to validate and calculate specifications for power accessories. For general theoretical background, you can read the Battery Charger Wikipedia entry.
Features
- Watt-Hour Calculation: Easily convert battery capacity (mAh) and voltage to Wh.
- Charge Time Estimation: Estimate charge times using a two-phase model (Constant Current up to 80%, Constant Voltage down to 100%).
- Effective Capacity Calculation: Calculate actual deliverable capacity (mAh) when a power bank discharges at 5V, 9V, or 12V instead of its nominal cell voltage (3.7V).
- USB-PD Profiling: Diagnose if your charger wattage matches your device requirements.
Installation
pip install cairovolt-charge-calc
Usage
1. Estimating Charging Time
This helper estimates the real-world charging duration based on your battery capacity and charger output. For example, if you want to calculate how fast an anker power bank or portable battery will charge, you can run the following script:
from cairovolt_charge_calc.core import ChargingCalculator
calc = ChargingCalculator()
specs = calc.calculate_charge_time(battery_mah=10000, charger_watts=20)
print(specs["total_charge_time_formatted"]) # Output: e.g., 5h 9m
2. Validating Device Specs
You can check if a specific charger is suitable for charging accessories. For instance, testing a premium audio device like the anker soundcore r50i wireless earbuds against a low-power USB port:
from cairovolt_charge_calc.core import ChargingCalculator
calc = ChargingCalculator()
diag = calc.verify_usb_pd_compatibility(device_required_watts=5, charger_output_watts=10)
print(diag["status"]) # Output: Optimal
To learn more about the USB charging specifications, check the USB Power Delivery on Wikipedia article or visit the Anker Official website for real-world equipment examples.
For guidelines on publishing your own packages, refer to the Python Packaging Guide.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cairovolt_charge_calc-1.0.0.tar.gz.
File metadata
- Download URL: cairovolt_charge_calc-1.0.0.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b642f94abeee3b7a89f45292919a2079a5581a64228f1f2fe5bd775bbb603119
|
|
| MD5 |
02ebed38096e965a78a80eb43ac27f07
|
|
| BLAKE2b-256 |
858a045516e3f04d6f28bdcf6949ab49c8b56979c91b74915b6fb70a55ce3682
|
File details
Details for the file cairovolt_charge_calc-1.0.0-py3-none-any.whl.
File metadata
- Download URL: cairovolt_charge_calc-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d08cd139f60a183d72f67db977ae24eeaa5b056b6f0b40297a599e49882b131c
|
|
| MD5 |
3a44839ebd7d6dcbfb269eef42f3405a
|
|
| BLAKE2b-256 |
40c29606ee63606fd81b672804e904ed491366730486e725494d3996cfb27eba
|