Closed Achronite closed 1 year ago
Thoughts: Could try using the table here: https://en.wikipedia.org/wiki/Alkaline_battery#Voltage
New code for calculation released to development branch based on the values above:
let v = msg[key]/batteries;
let charge = 0;
if (v >= 1.55){
charge = 100;
} else if (v < 1.1 ){
charge = 0
} else if (v < 1.18 ){
charge = 5;
} else {
// use a simple linear equation for the rest (y=mx+c), based on 1.44v=90% and 1.2v=10%
charge = (333.3*v) - 390;
}
After some testing, when the switch statement for battery % calculation uses this formula: 9412 - 23449(v/batteries) + 19240(vv/batteries) - 5176(vvv/batteries)
It does not seem to work properly and can return a -ve value. Fix this to work!