TO ADD A ON/OFF SWITCH TO YOUR RASPBERRY PI
As you will know the raspberry pi does not have an on/off switch - leaving you with the option of just shutting it down with the command
sudo power off
and then pulling the connector out of the raspberry pi pcb or alternatively pulling the psu out of the wall socket - which can result in a corrupt sd card, so that next time you try to boot the raspberry pi it will end in failure
first step - modify the boot config
file
sudo nano
/boot/config.txt
AND THEN ADD THE BELOW LINE OF SCRIPT
dtoverlay=gpio-shutdown
insert the script on the last line of the config file under <ALL>
Next comes the hardware i.e. a push switch (a momentary action type) i.e. its normally open, you push it and then it returns back to its original normally open state
Solder a couple of leads to the switch and connect these to leads to pin 5 and 6 of the raspberry pi GPIO header
(You can buy a switch with the leads already attached)
all you need to do to safely power down the raspberry pi is to press the switch once - press it again to 'wake' it up - leave the psu in the wall and the cable in the PWR connector on the raspberry pcb
if you feel that you don't want to modify the boot config file you could just shut the pi down with sudo poweroff and then just short momentarily pins 5 and 6 ( or 5 and 39 ) to power it up again which is a lot better than pulling the power cable out
The above worked ok on a pi model 3b v1.2 it also worked on a pi model 3b+ version 1.3 -- on another pi model 3b+ version 1.3 it would not work, all units were running buster 10, it would seem to be a firmware issue on the pi itself and not the operating system - it also worked with no problems on a pi4 with the latest buster 10
If for some reason the above does not work for you try the below method
sudo nano /boot/config.txt
Then insert below line at bottom of the page
dtoverlay=gpio-shutdown,gpio_pin=5
now if pin 29 (gpio 5) and pin 30 (gnd) are shorted (via a switch ) the raspberry pi will power down without the risk of corrupting the sd card (note 'red'power light will still be lit,but now its safe to unplug the raspberry pi
to re-start the raspberry with this method you need to use your inline power on/off switch or re-plug the power supply connector
to check what version of software you
are running
cat /etc/os-release
A simple way to check which raspberry model you have is:-
cat /proc/device-tree/model
or more elegant
pinout
le site est encore en construction - mais tous les liens travailleront