Hello all - I've built a simple locking circuit using a 3.3V 8MHz Pro Mini (ATMega 328P), capacitive fingerprint scanner, and microservo motor. The code works perfectly but I'm running into a problem when trying to take it mobile; I plan to move the project to a ATMEGA328P Breakout board (https://www.tindie.com/products/kdcircuits/328-board-atmega328p-breakout/), and eventually do the KICAD deal to avoid unused pins, BUT I need guidance on implementing a rechargeable battery.
I have a 3.7v 1000mAH battery that i need to have permanently connected to the circuit, and able to recharge without damaging the battery, or system. I have it soldered (correctly) to a TP4056 with USB-C, and then wired to RAW and GND, but when i try charging via USB-C to computer 'something goes wrong'. My explicit questions:
Do I need to run a 5V board and boost converter in order to have a rechargeable battery / device?
If not, how do i safely and permanently attach my battery to a 3.3V board, so that it's able to recharge without having to disconnect anything?
The TP4056 is not designed to charge a LiPo battery when it is connected to anything else. It won't work correctly in your situation unless you add circuitry to disconnect the battery while charging.
There are, to my knowledge, no general purpose modules that can handle in-circuit charging, because each application is different.
A much better approach for an infrequently used application like yours is to use 2xAA or AAA alkaline batteries to power the system, and have the processor in deep sleep most of the time, with the other modules powered off. If properly configured, you expect the batteries to last for years.
@jremington: Thanks for the feedback! I'm building a sealed device so the AA / AAA option isn't ideal for my project. I'm interested in the mentioned "circuitry to disconnect the battery while charging" - can you help me with a jumping off point (keyword for this type of circuitry) so I can do some research? So far, the common workaround i've seen is the 5V/boost converter option.
Also, trying to avoid having to implement an ON/OFF switch just to charge. The build / logic I'm after is tending towards that of late model cell phones and devices with fingerprint scanners that are in 'deep sleep' until the sensor is triggered. My idea was to have the system read/poll the sensor every so often to avoid a "forever waiting" condition...unless there's a better way.
The Arduino MKR Wifi 1010 has this feature/circuitry that can charge LiPo while USB power is connected
Battery Power
Its USB port can be used to supply power (5V) to the board. It has a Li-Po charging circuit that allows the Arduino MKR WiFi 1010 to run on battery power or an external 5 volt source, charging the Li-Po battery while running on external power. Switching from one source to the other is done automatically.
This might work for your requirement, and you get extra Wifi and a more powerul CPU
Why have you assumed that its a lithium battery that you must use ?
There are no general purpose circuits\modules that I am aware of that are 'safe' to allow a Lithium battery to be charged when its also in use.
There is a simple way of charging Lithium batteries whilst they are in use, but you need to limit the maximum charge voltage to a low value, say 3.9V, and the maximum charge current, which results in reduced capacity from the battery.
Yes. Smartphone manufacturers have hordes of professional EEs who custom design everything and the results are tested until believed to be foolproof. Nevertheless, as you are probably aware, there are still catastrophic failures from time to time. Lithium battery circuit design is not safe or advised for hobbyists.
If a gizmo needs to be rechargeable, then NiCD or NiMH batteries are an excellent choice. They can be "trickle charged" indefinitely without special circuitry. Batteryuniversity.com is a good resource for charging info.
tiger23:
Hello all - I've built a simple locking circuit using a 3.3V 8MHz Pro Mini (ATMega 328P), capacitive fingerprint scanner, and microservo motor. The code works perfectly but I'm running into a problem when trying to take it mobile; I plan to move the project to a ATMEGA328P Breakout board (https://www.tindie.com/products/kdcircuits/328-board-atmega328p-breakout/), and eventually do the KICAD deal to avoid unused pins, BUT I need guidance on implementing a rechargeable battery.
I have a 3.7v 1000mAH battery that i need to have permanently connected to the circuit, and able to recharge without damaging the battery, or system. I have it soldered (correctly) to a TP4056 with USB-C, and then wired to RAW and GND, but when i try charging via USB-C to computer 'something goes wrong'. My explicit questions:
Do I need to run a 5V board and boost converter in order to have a rechargeable battery / device?
If not, how do i safely and permanently attach my battery to a 3.3V board, so that it's able to recharge without having to disconnect anything?
Thanks for the help!
First, I think you need to get to the bottom of why your circuit doesn't work when rigged for mobile. But it's not clear - does it work ok on battery alone, but not when USB-C is plugged in? Can you be more specific about "something goes wrong"?
You should not need to boost to 5V. But if the scanner and motor will tolerate it, your Pro Mini would work fine if you apply power directly to Vcc, bypassing the regulator. It will tolerate up to 5.5V, and the battery and charger will never be higher than 4.2V. But sometimes sensors need exactly 3.3V, so you would have to check on that.
The feature needed to safely operate the device while charging the battery is called a load sharing circuit. As jremington said, I made a video on that. But whether you need that or not depends on how much current your circuit draws, and whether it sleeps a lot at low current.
But first you need to get the existing TP4056 setup working. Do you have a schematic drawing of your circuit? What is the value of the charge current resistor of the TP4056?
@hrznbgy: i appreciate the suggestion, though that's a bit more functionality than i need. I don't need wifi connectivity, and for such a simple mechanism i'm trying to keep the device as simple as possible. I'm not married to the LiPo battery BUT it is the most slim option and in trying to keep things compact my search led me to this battery type.
@jremmington: I watched the load sharing video and it was very helpful, thaks - i'm researching NiCD and NiMH batteries to see if I can find something similarly sized for my application. I'm a mechE but am in no way an expert so may just avoid heartache if there's not a safe way to implement LiPo batteries here
@ShermanP: First, thanks for your video! I'll follow this post with a schematic. It works perfectly when my battery is wired directly to RAW / GND (no TP4056). When 'something goes wrong' I have the battery wired to the TP4056 and pinned to RAW and GND on my pro mini. The USB-C was just my preference for TP4056 'type. When everything is hooked up, I plugged a usb cord from my laptop to the TP4056 to attempt a charge while all components were connected and got a red light on the TP4056, and it no longer powered the circuit even when unplugged from the computer.
I'm still unclear about when things work and when they don't.
If you connect the battery to the TP4056 module, but do not connect the USB cable, does your circuit work then when you connect the module to it - does it power up and run properly?
If it does, and you then connect the USB while everything is running, does it continue to run or does it shut down?
If you disconnect the servo motor from the circuit, and just have the control line turn on an LED (through a resistor) instead, does everything work then, including having USB connected?
If you disconnect your circuit from the module, does the battery then charge correctly?
The resistor I was asking about is R3. This is Rprog as shown on that link to your module. It may be something like 1.2K. It determines the charging current.
I suspect the problem is related in some way to the servo. Servos can draw large amounts of current when first powered up. The last one I tested drew almost 600mA for a few milliseconds. And if that is happening, it could be messing up the TP4056, or could even be triggering the protection circuit of the battery. But I don't see how adding any kind of voltage regulator is going to help.
As far as load sharing is concerned, it's only three components that wouldn't take up much space. But I'm not sure that would help this situation because I'm not sure what's going wrong. I'm very much interested in the answer to my first question above.
@ original question: usually you want to avoid switching regulators when aiming for low power circuit. They have too large quiescent current. If it must be used it is worth to use some way to disable it during sleep periods.