How to switch off XIAO ESP32C3 when battery power is lower than 3v?

Hello,

What is the best way not to destroy the rechargeable battery to not let it go under 3v ?
How can I close all circuitry including XIAO and also L298N when battery is too low ?

Thank you

1 Like

I had the same need for a custom board. There are three approaches each one has advantages and disadvantages:

Add a battery protection module to your Lithium cell. These protection modules will automatically prevent power withdraw when it would draw the battery below a safe level. The better ones also limit current into the battery when charging and limit voltage to prevent over charging. They are $8.99 for 12 pcs on Amazon. For single cell systems this is the easiest way to go but I have had a few die when the cell still seemed fine.

For my 12V systems I ended up using LM5164 regulator with a VIN pin. In this regulator it compares EN pin voltage to it’s onboard precision voltage regulator so I used a voltage divider. When VSS dropped below 10.86V the voltage on the enable pin dropped below the EN voltage of 1.1V. For my setup this worked out as VSS R1 = 1M, R2 = 160K with a 10Uf charge capacitor which helps debounce. Of course you still have some voltage loss across the 1M leg of voltage divider so it is not absolute protection from further draining. You can reduce risk of long term drain by increasing the 1M leg to 10M. You don’t actually need another regulator for your module but the same idea can be made to work. This does cause about a 1 second delay for power as the EN capacitor charges one VCC is supplied. You can accomplish something very similar using a voltage comparator but it is hard to beat this chip for it’s shutdown leakage current. It’s always nice to do it in simple components so a software glitch can not ruin a battery.

Another way I have done this using a low side mosfet with gate drained to ground between CPU GND and battery ground through a 1M resistor. If the CPU does not hold a pin high to power the gate then the entire CPU circuit gets disconnected from battery ground and can no longer draw power. This is a low cost and very reliable mechanism but I had to implement a voltage divider for the CPU on VSS so it could measure VSS Battery voltage and then have CPU turn off power when it sensed voltage dropped to low. The problem with this approach is you need a way to bootstrap the CPU back to life. I did this by a bypass press button switch that bypasses the mosfet until the CPU can drive gate voltage high. In my solar powered systems I cheat and allow PV+ to charge the gate to repower the system once we have renewable energy coming in. I also default solar power charge to battery on with default biasing of gates so the CPU has to drive a pin low to turn off the battery charging which also required adding a 816 optocoupler to protect that CPU pin. Technically you don’t need the battery charging logic if you are using a dedicated chip for that function but I figured that if the CPU is wanting to disable solar charge then we can spare the power to drive the optocoupler and this gave me 20 amp charge capacity with relatively low cost components and I needed the PV powered CPU bootstrap anyway.

vdiv-preg-enable-Screenshot 2024-05-04 003151

Hi there,
I use a small lipo with its own BMS , under and over (E) protection. The Xiao has an LDO built in , SO no chance to damage it. It won’t reset below 2.8vDC. Its been working for 3 years now NO issue. SO pair the right battery.
HTH
GL :slight_smile: PJ :v: