I'm doing a little project using a Lipoly charger and a 2500mAh 3.7V battery, both from Adafruit. I'm trying to display the percentage left on the battery. For that I'm using this little sketch :
long readVcc() {
long result;
// Read 1.1V reference against AVcc
ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
delay(2); // Wait for Vref to settle
ADCSRA |= _BV(ADSC); // Convert
while (bit_is_set(ADCSRA,ADSC));
result = ADCL;
result |= ADCH<<8;
result = 1126400L / result; // Back-calculate AVcc in mV
return result;
}
I saw on that page that the minimum voltage is 3.0V so I use that to get my values :
float volt = (float)readVcc()/1000;
float percent = ((volt-3)/0.7)*100;
When I display my values, it shows me that the percentage left is -4%. Should I worry or am I doing something wrong while calculating?