Powering a pro micro board with li-ion battery and USB connector

I want to power a pro micro board at 3.3v and 8 MHz with a 3.7 V Li-ion battery in a way that I can charge the battery with the USB connector on the pro micro board, and still be able to use the USB to transfer sketches or as serial monitor.

I may use a TP4056 based Li-iion charger module like this one:

My thought is to wire the RAW pin of the pro micro board to the + pin of the battery charger. That would provide about 4.8V to the battery charger module when the pro micro USB is plugged to a power source.

Then I would wire the OUT+ of the battery charger module to the VCC pin of the pro micro board through a 3.3v regulator.

Would that work like this?.
Or may it be necessary to remove the voltage regulator on the pro micro board?

This is an interesting idea, but it seems to me that you already have a 3.3V regulator. So what you need is a circuit that connects the battery to the RAW input when USB is not connected, but which simply disconnects the battery from RAW when USB is connected. Then you would connect the V+ USB pin (UVCC on my schematic) on the Micro back to the V+ input of the charger.

So when USB is powered, it would supply both the charger and the Micro's UVCC. But since the battery is disconnected from the Micro, it would continue to charge independently to completion. And of course when USB is not connected, the battery would supply the Micro's regulator.

This is what's called a load sharing circuit, which permits using the device while properly charging the battery. It can usually be implemented with a P-channel mosfet, a shottky diode and a resistor. And I think the diode is already there on the Micro.

Take a look a Microchip's AN1149 application note. Different charger, but same idea.

I drew a schematic showing what I think is the way to do this. In addition to the charger module and the lipo battery, you'll need to get a P-channel mosfet that will handle the maximum current you expect the Micro to need, and which turns on fully at maybe -2.5V G/S voltage or so, and a resistor. If the D2 diode is a regular diode, not a shottky, then the resistor can be something like 100K. If it's a shottky, something lower may be needed because shottky diodes may have significant reverse-biased leakage current. You just don't want the battery voltage to leak back through D2 and end up trying to turn on the charger or turn the mosfet off.

So the idea is that when USB is not connected, the mosfet gate resistor pulls the gate to ground, which turns on the mosfet, and the battery drives the Micro at the RAW input. Of course a diode would also work, but then you waste battery power because of the voltage drop across the diode. The mosfet is just an "ideal" diode equivalent which has almost no voltage drop.

Then when you connect USB power, the gate is brought high, which turns off the mosfet. At the same time, because of the mosfet's orientation its body diode also blocks any USB power from coming back into the batttery. That's necessary so the charger can tell when charging has completed. So USB is supplying power to both the charger and the Micro, independently, which should work fine so long as your USB source can provide enough current.

This works only for the 3.3V Micro.

If you try it this way, please let me know if it works.

I might have a solution:

Attach a cable that fits your Li-ion battery and splice the power wires to the + and - terminals of an old pro-micro cable, then you can plug the cable into your computer and remove it without taking off the battery.

power ardino and program.png

ShermanP:
I drew a schematic showing what I think is the way to do this. In addition to the charger module and the lipo battery, you'll need to get a P-channel mosfet that will handle the maximum current you expect the Micro to need, and which turns on fully at maybe -2.5V G/S voltage or so, and a resistor.

Thank you very much for this. I think this might indeed work, and the idea of the mosfet is an excellent one!. I'm almost sure the D2 diode is a regular one. I think its only purpose is to protect whatever is connected to the USB (possibly a computer) from getting an undesirable voltage from the RAW pin.

About your circuit, I'm unsure about the best way to pick up the UVCC. I suppose this implies messing a bit with the pro micro board. Maybe I can take it from the left side of the J1 jumper on the schema?, so I still have the 500 mA fuse operational? Or is there a better way that you can think of?

My initial thought was to use the RAW pin, not as a power input, but as source of power to charge the battery. I noted that when I plug the USB connector, I have about 4.8 V there. I suppose it is not exactly 5V because of the voltage drop in the existing D2 diode. Then I would use the VCC pin to supply power (3.3v) to the system. This requires an external voltage regulator (and the one available in the pro micro would remain unused). The mosfet circuit that you suggested for "load sharing" is still applicable in exactly the same way, except that it would have a 3.3v regulator after it and will be connected to the VCC pin.

I have some questions:

It puzzles me that when nothing is plugged in the USB connector, and a stable 3.3V source is connected to VCC, there's 3.3V in the RAW pin. I do not understand why?. Does this imply that the voltage regulator on the board leaks tension in the opposite direction? Is this something to be expected?

Also, in case I decide to go to my approach (just to avoid excessive messing with the pro micro board). Do you think that the existing 3.3v regulator on the pro micro board can cause some problem (because to some extent we would have two regulators working in parallel when the USB cable is connected)?

Finally, please can you suggest a suitable P-channel mosfet that would do it?. I have long experience in software development (much before arduino), but not that much on electronics or hardware components. I mean, I understand basic electronic circuitry, but it would be great if you point me to at least a family of suitable p-channel mosfets for that application. I have yet to determine the exact consumption of the project, but I 'guesstimate' that it will be no more than 100mA. The project consists on the pro-micro board, the battery charger + battery, a 1.3" oled display, and a nrf24l01 module.

Thanks!

joanlluch:
Thank you very much for this. I think this might indeed work, and the idea of the mosfet is an excellent one!. I'm almost sure the D2 diode is a regular one. I think its only purpose is to protect whatever is connected to the USB (possibly a computer) from getting an undesirable voltage from the RAW pin.

Yes, I think that's right.

About your circuit, I'm unsure about the best way to pick up the UVCC. I suppose this implies messing a bit with the pro micro board. Maybe I can take it from the left side of the J1 jumper on the schema?, so I still have the 500 mA fuse operational? Or is there a better way that you can think of?

I don't have a Micro to look at, so I can't say for sure. But if you can solder a wire to VBUS1 at the USB connector, or on the high side of the fuse, I think that would be a good tie in to UVCC. You would still have the fuse for the Micro, but the fuse wouldn't limit battery charging. If you tie in after the fuse, then the combined charging current and Micro current will be limited to 500ma, realistically more like 400ma, and that may extend your charging time significantly. Of course the other option is to just remove the fuse, which would also probably give you an easy tie-in point. My Mini doesn't have such a fuse. I don't know about the other Arduinos.

My initial thought was to use the RAW pin, not as a power input, but as source of power to charge the battery. I noted that when I plug the USB connector, I have about 4.8 V there. I suppose it is not exactly 5V because of the voltage drop in the existing D2 diode. Then I would use the VCC pin to supply power (3.3v) to the system. This requires an external voltage regulator (and the one available in the pro micro would remain unused). The mosfet circuit that you suggested for "load sharing" is still applicable in exactly the same way, except that it would have a 3.3v regulator after it and will be connected to the VCC pin.

I'm having difficulty picturing how that would work. But if you want to sketch out what you have in mind, I'll look at it. But you would still have the fuse limiting your charging current.

I have some questions:

It puzzles me that when nothing is plugged in the USB connector, and a stable 3.3V source is connected to VCC, there's 3.3V in the RAW pin. I do not understand why?. Does this imply that the voltage regulator on the board leaks tension in the opposite direction? Is this something to be expected?

That puzzles me too. Some regulators have protection diodes going from output to input, but then there would be a diode drop. I don't think the MIC5219 shown on my schematic has that. It would not be unusual to have some voltage show up on RAW, but I don't understand how it could be equal to the Vcc input voltage.

Also, in case I decide to go to my approach (just to avoid excessive messing with the pro micro board). Do you think that the existing 3.3v regulator on the pro micro board can cause some problem (because to some extent we would have two regulators working in parallel when the USB cable is connected)?

Well, you would have to prevent that situation from happening because you can't have the battery powering your external regulator while it's being charged. So both regulators can't be on at the same time. What's not clear is how you would accomplish that.

Finally, please can you suggest a suitable P-channel mosfet that would do it?. I have long experience in software development (much before arduino), but not that much on electronics or hardware components. I mean, I understand basic electronic circuitry, but it would be great if you point me to at least a family of suitable p-channel mosfets for that application. I have yet to determine the exact consumption of the project, but I 'guesstimate' that it will be no more than 100mA. The project consists on the pro-micro board, the battery charger + battery, a 1.3" oled display, and a nrf24l01 module.

The mosfet only has to handle what the battery will supply, which is everything except the charger. But for 100ma, you might look at the TP2104. It's kind of a middling mosfet, not great on any spec, but does pretty well. More expensive, and more capable, would be the LP0701. Both come in through-hole TO-92 packages as well as surface mount.

Thanks!

You're welcome.

Hi ShermanP,

Thank you very much for your replies as they are very useful to me. I finally decided to go for an approach based to your suggestion. Please look at the attached schematic.

Instead of using a TP4056 board module I will use the chip itself and will add all the required components around it. The UVCC will be taken from the Pro Micro board J1 bridge. This will pass all the current through the fuse on the Pro Micro board, but I configured the TP4056 to take a maximum of about 255mA when charging the battery by using a 4k7 resistor for R4, so I suppose the fuse should not blow.

I still need to check the total consumption of the remaining circuitry in practice, but I believe it should be significantly below the 100 mA that I stated before. Maybe around 20 to 30 mA at most.

I will also implement some power saving code, such as switching off the radio on idle periods, or even go that far as to use the clock pre-scaler to put it all on nearly sleep when possible. The aim is to be able to use a battery pack as small as possible, so it needs less current to get fully charged.

I would appreciate that you look at my schematic (based on your suggestion), so maybe you find something that can be improved or wrong. I particularly am unsure if the capacitor that I have put in parallel to the battery is required. I found that on the datasheet of the TP4056.

Thanks in advance!

The schematic looks pretty good. Tying in at the jumper is a convenient place. Just make sure you tie only to one half of the jumper so it remains "un-jumpered" for 3.3V operation.

I'm not sure the battery capacitor shown in the datasheet is really necessary, but it looks like the modules include it, so I'd suggest you include it too.

The only thing I noticed on the schematic concerns LED resistors. I would suspect that the two charging LEDs would be bright enough with larger resistors, like 2.2K or 3.3K, and that would save some current. But on the other side, you have a 47K resistor (R1) on LED1, and I'm not sure it would light up at all with that much resistance.

Before putting this together, if you have a way to apply 5V or more to RAW, but with USB not plugged in, it would be good to measure the voltage at the jumper terminal with the R5 100K resistor tied from there to ground. The idea is to see how much current leaks back through D2. The resistor should take the jumper terminal pretty close to zero volts. If it doesn't, you may need to change it to 47K or lower.

You will find that LIPO batteries come in a variety of sizes. Just make sure yours has built in protection circuitry. The TP4056 doesn't include that.

I think this is going to work fine.

Hi ShermanP,

Thanks again for your input.

Yes, I suppose it would be wiser to have higher value resistor for the charging leds in order to reduce a bit the consumption (actually, they are meant to be a single two-colour led, but that doesn't affect the discussion) . However, my understanding is that these only light when the USB connector is plugged, so I suppose they should not affect battery life.

About the 47K resistor for LED1, you are right it looks too big, but I tested it in practice and it's just what I want. For testing purposes, I started with a regular 5 mm LED from the breadboard kit that lighted fine with a 1K resistor, then I replaced that by a 3 mm white LED that I purchased on a local store and found that it lighted too much. I kept increasing the resistor value until it looked right to me. I have no idea about what kind of led is that, but I have a two 100K resistors in parallel (so 50K) connected to the LED, and it lights the way I want to. That's good news for the purposes of the project because that means less power consumption (See first photo attachment for the led looks when lighted. It's more than enough for my needs)

About consumption I found that the circuit to be battery powered takes a maximum of 24 mA continuous current (see second attachment). When the Oled screen goes to sleep (just by turning it blank) the whole thing consumes 12.5mA (see third attachment). This is with the radio configured as RF24_PA_LOW but powered up at all times and continuously communicating with another Arduino every 50 ms. This means that I have still huge potential to reduce consumption even further when iddle, and thus I may go fine with only a 300 mAh battery for a life of at least 15 continuous use hours, or more when taking into account iddle periods.

I will check the voltages you suggest when I have the switching power circuit ready (I don't even have the electronic components yet). So far, I checked the voltages at the jumper ends with the USB connected, and as expected, it's 5V on one end and 3.3V on the other end, so I now know what end I must connect the UVCC pin to :-).

So thanks for everything.

IMG_3568.JPG

IMG_3562.JPG

IMG_3561.jpg

Hi ShermanP,

Please also look at my previous reply.

Ok, so following your suggestion I applied 5V to RAW, placed a 100K resistor between ground and the 'UVCC' terminal of the Jumper, and it's 0.012V. Without the resistor, the voltage there was 0.05V.

Do you think that figures are good enough for our purposes?

Thanks.

You're right about the charging LEDs. They have no effect on battery life.

I think your power usage is well within the range of being battery powered. And as you say, you may find further improvement to reduce current even more. But you may find that you can get a good bit more battery power with not much added battery size.

That's an amazingly efficient white LED. I need to get some of those.

joanlluch:
Ok, so following your suggestion I applied 5V to RAW, placed a 100K resistor between ground and the 'UVCC' terminal of the Jumper, and it's 0.012V. Without the resistor, the voltage there was 0.05V.

Do you think that figures are good enough for our purposes?

That's perfect. I think it confirms that D2 is a regular diode with almost no leakage. In any case, it appears the 100K will work fine.

Here's a link to some boards that can be very convenient when it comes time to transfer the circuit from your breadboard to a soldered version, and rescue your breadboard for other things. They can save you from having to design and order a PC board, and they generally reproduce the breadboard format, although not an exact match.

https://www.ebay.com/itm/112951198754

Hi ShermanP,

Thanks again for your response.

I have a lot of the classic 90x70 mm boards with individual holes spaced at 2.54 mm from China that many years ago I used to use for finished little projects. But currently, with services like JLCPCB there's no need to bother with them or the photo-sensitive ones any longer.

The kind of boards that you pointed out to me are certainly more convenient. I can see them being used to store projects as in their prototyping stage, and possibly test critical components on them. For some reason the ebay link you provided does not ship to my country, but I found identical boards in China and I have already ordered some!.

Following my previous questions. It now occurs to me that It would be nice to have an indication of the battery voltage in the arduino. I suppose I could simply input a fraction of the battery voltage to an analog input pin by means of a voltage divisor with two resistors, but I am not sure whether that simple approach would actually work because the arduino voltage reference would ultimately com from the battery, and I guess I would need a more constant reference(?). On the other hand having such voltage divisor always on would add an additional load to the system.

So I researched a bit the issue and I found this circuit on the internet:http://blog.zakkemble.net/wp-content/uploads/2013/05/MCP73831_loadshare_mcu2.png

The relevant circuit for my question is on the bottom centre. To my understanding, this uses a digital output to activate a voltage divisor, possibly only run briefly at regular intervals to minimise power consumption. The divisor is created around R6 and R7, and it inputs a proportion of the battery voltage to an analog input. I suppose it might work and it's simple enough, but in that particular circuit the MPU is powered at 2.5V while the battery should never go below 3V.

My project, on the other hand, is meant to use a 3.7V nominal battery, and it uses the 3.3V regulator existing on the pro micro board. There's not a lot of voltage drop for the regulator, so I wonder what would happen when the battery goes down to below 3.5 or 3.3V.

Any suggestions?

Your battery will charge up to 4.2V, or more likely 4.15V or so, and it will remain above the nominal 3.7V for most of its discharge time. So if 3.5V still complies with the regulator's datasheet dropout limit at the current you plan to draw (it needs more room at higher currents), then you should be fine. But as the battery voltage drops below what the regulator needs to maintain 3.3V, the results become unpredictable. The regulator may just follow the voltage down, but it certainly won't be regulated anymore. So you don't want to go there. So the first stop is to the datasheet to see what you're dealing with (i.e. - what does "LDO" really mean at your target current).

If you find you aren't getting enough time between charges, the best solution is to use a larger battery. But of course that means longer charging times. No free lunches with batteries.

By the way that Zak Kemble site is really good. He has the best explanation of load sharing I've seen, including exactly how you calculate what the gate pulldown resistor needs to be to offset leakage through D2.

As long as you have regulated 3.3V, your analog reads will be based on 3.3V, no matter what the battery voltage is. And as you say, you only have to turn on the resistor divider when you're taking a reading, so the current usage won't be material.

Hi ShermanP,

Ok, that makes sense. If the 3.3v voltage regulator on the Chinese pro micro clone board is actually a MIC5219 as stated on the schematic, then its typical dropout voltage at 50mA is 175mV (or 250mV max). This means for the typical figure that we are safe until 3.475V or less given that I will not be using 50mA. You mentioned an even more conservative value of 3.5V so I'm glad to know that.

Following another aspect of my project, I am also posting a question on a possible NRF24L01 antenna. This is the link on the forums in case you want to participate: Nrf24l01 in aluminium case, SMA connector mod. - Project Guidance - Arduino Forum

I think everything is now clear to me regarding the battery charger and load sharing feature. Your help has been very mush appreciated.