The Raspberry Pi needs a proper shutdown before the power goes off, otherwise your SD card can be corrupted. To shut down the Raspberry Pi the command
sudo shutdown -h now must be executed.
The 5V from the DC regulator will go through D1 and will power the Gate of Q1. While putting Q1 High C1 will start charging. And BCM_20 of the Raspberry Pi will go up.
The remaining voltage before D1 will drain through R1 to the ground. So BCM_20 will become LOW, and the following code will run.
if not GPIO.input(20):print('SYSTEM SHUTDOWN')call("sudo shutdown -h now", shell=True)
C1 will Load off his voltage to the Raspberry Pi, so that the Raspberry Pi has enough time to execute the command and shut down properly.
The shutdown time of the Raspberry Pi is +-20 seconds, to be sure of a proper shutdown 33 seconds is used.
IRFZ44N belongs to the family of N-channel Power MOSFETs, covered in plastic body and uses “Trench” technology. Its features include very low on state resistance, high speed processing technology, completely avalanche rated etc. Push pull systems and full bridge are a few of its real life applications.
IRF-Z44N has a few major features. For this project the IRFZ44N is used for his Fast switching capability and ultra low charge on the gate.
Electronic Components- Syed Zain Nasir(9/10/17)[SOURCE]