Page 1 of 2
Battery charge time
Posted: 10 Dec 2019 12:41
by Lucy
Hey, can we determine the average time till battery is full charge and/or vice versa? So far i have created flows to log battery charge start and end times with duration count, app usage in between with data usage also and duration count. I have also been logging 10% drops and increases from 0-10 scale and vice versa (also with app monitor in between). The idea was to run these battery draining flows for a week or so. Then i can evaluate all the results and come up with an average charge time that changes depending on phone state, app usage, etc. Just like you see on the lock screen of android when phone is charging. as well as app statistics as a bonus. This is what i jave been working on and is why all the random questions (mostly). Anyway, as messy as it all is cause its still in development stage, it still works and logs enough data for me to get an estimate... that is if i have the time to decipher it all
is there a straight forward way to just implement it in the flow w/o all my handy work?
Re: Battery charge time
Posted: 10 Dec 2019 12:44
by Lucy
Obviously i can estimate with just my charge duration logs. But that is provided i simulate the same processes and wotnot, so that is no good and in no way accurate.
Re: Battery charge time
Posted: 10 Dec 2019 12:50
by Lucy
Even if i do eventually work out estimated values and determine most resource extensive use and all that, im still not too sure how to put it in to code properly. I mean i have theories but i unfortunately am restricted still to basic coding as you all know by now.
Re: Battery charge time
Posted: 10 Dec 2019 18:30
by Desmanto
It depends on too many variable : the charger used, the cable, phone condition, temperature, app running at the time, quick/fast charging, charging throttling, display on slowdown, near full slow down, battery age, battery calibration and many others. I just wonder if the accuracy can be trustworthy.
The simplest way of course is to minus the current percent from 100%, times the battery capacity and divided by the incoming current. But as the current in varies during the charging, the estimate also change and can be misleading. I know you don't mind some error/deviation, but it is just I don't know yet the typical method to get a good estimate for it.
I ever thought about creating a similar flow but I have put it down so long. Maybe the closest and easy to do calculation is still using the current. But use at least 5-10 past current to estimate the trend of the usage. Example get a 5 seconds period of the current at 5 samples; average them. If it is minus (at mine, minus mean charging), then calculate toward 100%. If it is plus, calculate remaining torward 0% as it is being used.
Re: Battery charge time
Posted: 11 Dec 2019 13:17
by Lucy
Lol your simple idea seemed good enough for me to test and fool around with however... lol im doing something wrong because im getting negative values
Code: Select all
chargecheck = 100 - global_battery_percentage * 3000 / global_battery_current_now;
global_charge_time_left = getDurationString(chargecheck);
Re: Battery charge time
Posted: 11 Dec 2019 17:01
by Desmanto
What is the value of your battery_current_now when being charged? Is it negative or positive?
Assume that it is negative (most android I work with have minus value when being charged), then the formula should be
Code: Select all
chargecheck = (100 - global_battery_percentage) * 3000 / -global_battery_current_flow * 3600000;
global_charge_time_left = getDurationString(chargecheck);
We need bracket when subtracting, because that is the priority calculation. The current get minus sign to negate it. Then result is in hour. So we have to times it with 3600000 to get the millis.
Re: Battery charge time
Posted: 11 Dec 2019 17:46
by Lucy
-243 when not charging
-342 average
Will check charge.
I got an output of 6days, hours, minutes, etc.
It has been raising, now on 7days, nearly 8days
.
But hey... it is so much better than my output
Current_now whilst charging is "988"
Current is only in the negative when not plugged
Re: Battery charge time
Posted: 11 Dec 2019 18:38
by Lucy
Lol 18days now
Re: Battery charge time
Posted: 12 Dec 2019 06:29
by Desmanto
Sorry, I forgot the battery level is in percentage
, so we still have to divide by 100. Your charging current is positive, so you don't need to negate the current.
Code: Select all
chargecheck = (100 - global_battery_percentage) / 100.0 * 3000 / global_battery_current_flow * 3600000;
global_charge_time_left = getDurationString(chargecheck);
Re: Battery charge time
Posted: 12 Dec 2019 07:42
by Lucy
Cool... thankyou my favorite mathematical genius
Im gonna try it shortly.
Hey what about discharging formular, can we work that out?
Id asume the formula for that would be as simply as only 2 equations...
Maybe devide capacity from current maybe!?