I never needed the lo - minimum. Since the voltage division is linear, for calibration it should be enough to just measure the highest value ever, claim that it is e.g. 4.2 and then everything else is computed from that. So e.g. if maximum in F07 fitness tracker is 0.18 then
function battVolts(){
return 4.20/0.18*analogRead(D5);
}
Then I do percentage based on volts e.g. like
function battLevel(v){
var l=3.5,h=4.19;
v=v?v:battVolts();
if(v>=h)return 100;
if(v<=l)return 0;
return 100*(v-l)/(h-l);
}
But it doesn't matter much. Important is that only one measured value (maximum ever) seems to be enough.
it appears my high and low D3 readings are about 0.293 and 0.230 respectively, although I'm getting a sharp dropoff at about 0.255.
so for you
(4.20/0.293)*0.255 = 3.65V for the dropoff
(4.20/0.293)*0.230 = 3.29V for the minimum
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I never needed the
lo
- minimum. Since the voltage division is linear, for calibration it should be enough to just measure the highest value ever, claim that it is e.g. 4.2 and then everything else is computed from that. So e.g. if maximum in F07 fitness tracker is0.18
thenThen I do percentage based on volts e.g. like
But it doesn't matter much. Important is that only one measured value (maximum ever) seems to be enough.
so for you
(4.20/0.293)*0.255 = 3.65V for the dropoff
(4.20/0.293)*0.230 = 3.29V for the minimum