Checking Power outage for my Project

Thread Starter


Joined Oct 26, 2019
hello guys,
i am working on a project that include an esp32, a li-ion 3.7v battery and a battery controller charger TP4056 of 1A and 4.2V.
how the power supply of the project will work is i will connect the TP4056 charger to the battery and from the battery to the vin pin of the esp32,
my problem here is that the TP4056 will always be connected to power supply via USB connector it will not damage the battery as it is a charger controller, it knows when the battery is fully charged(my assumption) so when the battery is fully charged the TP4056 will power the esp32 directly until if the power supply is disconnected from the charger(TP4056) and when this happens, the battery will act as the power supply for device until the power supply is reconnected again. what i want is to monitor the time the power supply via the USB connector was disconnected in my esp32 code. the code part is fine i can use a voltage divider and using the analog to monitor it but the issue is that i will have to wait for a while for the battery to discharge which i do not want, i thought of diodes but they use currents not voltage... so can anyone suggest a solution it will be very helpful