Arduino and N mosfet lithium battery charging/discharging measuring capacity

arduinobattery-chargingdischargelithium ionmicrocontroller

enter image description hereI need an Arduino based lithium battery tester that uses N channel Mosfets to switch On charging from and external power source and discharging through a 2 Ohm resistor. I have no issues with either charging or discharging circuit schematic, however i can not combine them together. I'm attaching the schematic for discharging the battery into the 2 Ohm resistor, please help with adding the components for making it able to charge the battery from an external, let's say 4.2V power source, all controlled by Arduino.

I also need to have a state when i'm Not charging or discharging so i guess for that purpose i need to use Pin 11 on Arduino

Best Answer

Surely a high side PFET connecting the battery + terminal to the 4.2V external supply is enough. I hope you aren't doing anything unsafe, I really hope you've read about thermal issues, charge currents and voltage cycles with Lipo batties.

If you have the default logic state as the 4.2V thing connected to the battery, then have the system with a pull down resistor on Pin 12. Then when Pin 12 goes high, it will turn on the NFET low-side switch to provide the 2 Ohm load, and the gate voltage of the P fet will rise and turn it off, thus allowing you to test the battery without the 4.2V thing interfering.

You can swap the logic (not recommended, unless you also detach the battery when not in use) by putting a pull-up resistor on Pin 12 and driving it low to allow the battery to charge again.