Practicing Electronics
Learning Embedded Software
Circuit Design and Fabrication

To have zero-crossing power outage detection, use an Optocoupler.
 
Applying 230VAC through high resistance resisters to input to the optocoupler. The optocoupler's output of 50Hz pulse when power is available becomes the input to Rettrigerable Monostable Multivibrator.
The multivibrator's output holds high with every input pulse.

Without the AC supply, without the pulse from the optocoupler, the output of the monostable multivibrator is set to low.

12V auto cut-off unit for a battery charger for battery overcharge protection.