For switching on and off the Raspberry Pi, it is not advisable every time to insert and remove the micro USB power cable, it may damage the connector of the Raspberry Pi.
That’s why we’re going to connect a physical button that will turn it on and off properly with the command “shutdown”.
For this tutorial you will need :
- A Raspberry Pi, here I use the 3rd model;
- A push button;
- Two wires.
Here is the connection diagram :
To turn it on :
When the Raspberry PI has been properly shut down with the command “shutdown”, it is in a sleep state that consumes a minimum of current.
To turn it on, simply connect the GPIO3 and GND for a short while and this turns on the PI.
To turn it off :
Here it is a little less simple, but it remains within the reach of all 🙂
Type the following command sudo nano /boot/config.txt
At the end of this file, add this : dtoverlay=gpio-shutdown
Then type CTRL+o, ENTER to save your changes, and then CTRL-x to exit the text editor.
That’s it, you just have to properly shut down your Raspberry Pi with the sudo shutdown now
command.
Once turned off, press the button and the Raspberry Pi should turn on, wait 2 to 3 minutes until it finishes booting everything, and press the button again, the Raspberry Pi should turn off.
Good work 🙂