TinyCircuits

TinyCircuits Products => TinyDuino => Topic started by: riphill on May 16, 2016, 07:10:32 AM

Title: Battery charge status/power remaining
Post by: riphill on May 16, 2016, 07:10:32 AM
Apologies if this has been asked before, but is there any way to check the charge status (ie approximate charge level) and estimate how long the battery would last at the current rate of discharge in use?
Title: Re: Battery charge status/power remaining
Post by: Ben Rose on May 16, 2016, 10:51:26 PM
I have a function we use to grab VCC on the AVR platform-
Code: [Select]
int getVCClevel(){
  //http://forum.arduino.cc/index.php?topic=133907.0
  const long InternalReferenceVoltage = 1100L;
  ADMUX = (0<<REFS1) | (1<<REFS0) | (0<<ADLAR) | (1<<MUX3) | (1<<MUX2) | (1<<MUX1) | (0<<MUX0);
  delay(1);
  ADCSRA |= _BV( ADSC );
  while( ( (ADCSRA & (1<<ADSC)) != 0 ) );
  int result = (((InternalReferenceVoltage * 1024L) / ADC) + 5L) / 10L;
  return result;//this should be in hundredths of a volt
}

You can use this and a general lithium ion discharge curve to guess approximate charge level.

Thanks,
Ben
Title: Re: Battery charge status/power remaining
Post by: riphill on May 25, 2016, 01:10:36 PM
Thanks,  I'll give that a go, should give an indication of how charged the battery is at least I hope, I never know how long to leave it on charge.  If I output to a some stats I guess I could get a picture of the discharge rate and maybe graph a curve.
Title: Re: Battery charge status/power remaining
Post by: amb9800 on August 12, 2016, 01:03:08 AM
I have a function we use to grab VCC on the AVR platform-
Code: [Select]
int getVCClevel(){
  //http://forum.arduino.cc/index.php?topic=133907.0
  const long InternalReferenceVoltage = 1100L;
  ADMUX = (0<<REFS1) | (1<<REFS0) | (0<<ADLAR) | (1<<MUX3) | (1<<MUX2) | (1<<MUX1) | (0<<MUX0);
  delay(1);
  ADCSRA |= _BV( ADSC );
  while( ( (ADCSRA & (1<<ADSC)) != 0 ) );
  int result = (((InternalReferenceVoltage * 1024L) / ADC) + 5L) / 10L;
  return result;//this should be in hundredths of a volt
}

You can use this and a general lithium ion discharge curve to guess approximate charge level.

Thanks,
Ben
Does the TinyScreen+ (ARM platform) have a similar function?
Title: Re: Battery charge status/power remaining
Post by: Ben Rose on August 15, 2016, 06:11:48 PM
It has a similar function, but the processor is running from a 3.3V regulator, so checking VCC isn't very useful except to check for a low battery <3.3V.

This is something we overlooked and should be able to fit on the next revision.
Title: Re: Battery charge status/power remaining
Post by: tastewar on August 16, 2016, 10:23:37 AM
Ben- when you say "fit on the next revision" are you referring to the hardware? Or next library revision... (hoping the latter, but guessing the former...)
Title: Re: Battery charge status/power remaining
Post by: Ben Rose on August 16, 2016, 04:40:26 PM
Yes, unfortunately hardware, it will probably just be a simple resistor voltage divider. There isn't a good software workaround unless you can tell the software when it has a full charge.

Keep in mind that the current hardware with the <3.3V low battery warning, which means maybe 5% capacity, can last a while in standby mode, depending on what else you have connected.
Title: Re: Battery charge status/power remaining
Post by: EMH333 on August 19, 2016, 06:11:25 PM
Yes, unfortunately hardware, it will probably just be a simple resistor voltage divider. There isn't a good software workaround unless you can tell the software when it has a full charge.

Keep in mind that the current hardware with the <3.3V low battery warning, which means maybe 5% capacity, can last a while in standby mode, depending on what else you have connected.

Excuse me for asking if this isn't appropriate. About how long till the new hardware revision? I want to build a smart watch soon but depending on the time frame would be willing to wait if it means I get to know the battery charge level.
Thanks for your help!