Lipo battery level and charging in a project

Hi,

For my next project I plan to use a 3.7v LiPo battery to power a 3.3v Arduino pro mini .
I would like to have the ability to check the battery level and charge it using a USB charger without removing the battery from the project.

I already figured out that I'll need a LiPo fuel gauge for measuring the battery level and also some sort of USB charging circuit for the charging procedure.

My questions are as following:

  1. How do I connect the battery to both the fuel gauge, charging circuit and arduino at the same time?
  2. Can someone recommend the a specific model of fuel gauge and charging circuit to use?

Thanks,

Meir :o

I'd recommend the ones that Sparkfun has; there is existing code, they have the chips on breakout boards.

Hi Meir,

I use the following function to check the battery level. It´s not mine, but I couldn´t find where I got it from:

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;

}

It returns the current level in mV.

For charging the battery, I use a standard TP4056 module that includes the microUSB connector. The Arduino board is powered directly from the 3.7V battery.

I hope it´s useful.

Regards!

Thanks very much.
If I understood correctly, you use the TP4056 to charge the battery. What do you use to measure the juice left in the battery and indicate that it needs to be charged?

Meir

Hi Meir,

For checking the batt level, I include the readvcc() code as a function. In my case, the sketch calls it every X minutes, but you call it on every iteration of your loop(). No extra hardware needed!

Here´s the source:

You get the current voltage in mV, and you can compare to your low-batt threshold.

Regards!

A 3.3V Pro Mini will operate just fine at up to 5.5V. So instead of powering it through the RAW pin, you could just connect the battery directly to the Vcc pin. That would let you measure the voltage at Vcc by using the fixed 1.1V reference level. But this won't work if your Mini has things connected to it that do require 3.3V.

With respect to charging, things can get complicated if you need to run your Mini while you are charging the battery. The Mini's current draw may confuse the charging circuit so that it never stops charging, which could be a safety issue. Do you know how much current your Mini circuit will draw? Will it be on all the time, or will it sleep a lot?

ShermanP:
A 3.3V Pro Mini will operate just fine at up to 5.5V. So instead of powering it through the RAW pin, you could just connect the battery directly to the Vcc pin. That would let you measure the voltage at Vcc by using the fixed 1.1V reference level. But this won’t work if your Mini has things connected to it that do require 3.3V.

With respect to charging, things can get complicated if you need to run your Mini while you are charging the battery. The Mini’s current draw may confuse the charging circuit so that it never stops charging, which could be a safety issue. Do you know how much current your Mini circuit will draw? Will it be on all the time, or will it sleep a lot?

ShermanP,

Thanks for the detailed reply. I didn’t think of that issue.
The mini is planned to be on all the time, light up several LEDs (~20 max) and read the time from an RTC module (DS1307 or similar) every few seconds.
Can you recommend a solution?

meirgold:
Thanks for the detailed reply. I didn't think of that issue.
The mini is planned to be on all the time, light up several LEDs (~20 max) and read the time from an RTC module (DS1307 or similar) every few seconds.
Can you recommend a solution?

Twenty LEDs? Well, I did a video on the charging problem on another circuit which includes a solution called a "load sharing" circuit. You can skip over the modification itself and look at alternatives listed at 18:50.

It really just comes down to how much current your project draws. If it's less than 10% of the full charging current, you're ok. Then you would see the red charging light go out when charging has completed. If it doesn't ever go out, you have a problem.

Do you have a schematic of your project?

ShermanP:
Twenty LEDs? Well, I did a video on the charging problem on another circuit which includes a solution called a "load sharing" circuit. You can skip over the modification itself and look at alternatives listed at 18:50.

Load Sharing for the 18650 Battery Shield V3 - YouTube

It really just comes down to how much current your project draws. If it's less than 10% of the full charging current, you're ok. Then you would see the red charging light go out when charging has completed. If it doesn't ever go out, you have a problem.

Do you have a schematic of your project?

Hi,

No schematics yet, still in the very early planning phase.
I watched the video and I will try to implement your suggestion of sending the device to sleep for long enough periods so the charging circuit will detect the battery is fully charged.

Thanks,

Meir