LYNXware / cat_esp32s3_rust

Apache License 2.0
0 stars 0 forks source link

Feature sleep-state and battery-state logging #14

Open Ben-PH opened 1 year ago

Ben-PH commented 1 year ago
will shortly be adding a python script similar to this: ```py def calculate_battery_life(B, I_active, I_light, I_deep, daily_usage, light_sleep_coef, deep_sleep_coef): active_time = daily_usage * (1 - deep_sleep_coef) # Calculate active time not in deep sleep I_avg = (active_time * ((1 - light_sleep_coef) * I_active + light_sleep_coef * I_light) + daily_usage * deep_sleep_coef * I_deep + (24 - daily_usage) * I_deep) / 24 # Calculate average current life = B / I_avg # Calculate battery life days = int(life // 24) hours = life % 24 return (days, hours) # Hardware estimations B = 2.6 # battery capacity in Ah I_active = 0.050 # active current draw in A I_light = 0.001 # light-sleep current draw in A I_deep = 0.00001 # deep-sleep current draw in A # Usage estimations daily_usage = 8 # average daily active-time in hours light_sleep_coef = 0.7 # average proportion of active-time spent in light-sleep deep_sleep_coef = 0.5 # average proportion of daily-usage spent in deep sleep (days, hours) = calculate_battery_life(B, I_active, I_light, I_deep, daily_usage, light_sleep_coef, deep_sleep_coef) print(f"Expected battery life: {days} days and {hours:.2f} hours") ```

It effectively makes some assumptions about power consumption in different sleep states, and calculates battery life based on average daily usage, and how much of that daily usage is spent in each sleep-state, assuming the non-daily usage is in deep-sleep.

e.g. with the above settings, a full change will last 41 days, plus another 6.48 hours of use.

If we can log the actual time spent in deep/light-sleep, and battery levels, we could calculate quite nicely the actual expected battery-remain in days/hours used. When we have an e-screen, we could provide a dashboard, and possibly even an assumptions modifier.