Your Raspberry Pi has frozen. Perhaps a new component has failed, or the system has ground to a halt processing some bad code. Either way, you now have to unplug and reconnect your Pi’s power supply as manually shutting down isn’t possible.
Removing and replacing the USB power cable isn’t ideal, and it is certainly putting undue wear and tear on your Raspberry Pi, particularly the power port itself. What the system really needs is a reset switch, but sadly none was included.
Fitting A Reset Switch To Your Raspberry Pi
It is relatively simple to add a reset switch. Three methods are available to you, each suited to a particular skill level. For the beginners, an inline power switch on the micro-USB cable powers your Pi is the easiest.
Are you more of an expert? If the USB reset button seems simplistic, using a jumper (a small plastic square housing some metal connectors) commonly found on motherboards or the back of PC hard disk is also an option.
For those of you happy to wield a soldering iron, however, you can also fit your own pins to the P6 header on your Raspberry Pi, and then connect a PC-style reset switch.
Let’s look at all three options in more detail.
Add An Inline Power Switch To Your Raspberry Pi
Quite clearly the simple option, adding a inline power switch to your Raspberry Pi saves you the hassle of playing with the GPIO header or even soldering your own pins to the board.
All you need to do with this device is connect it to the micro USB connector on your Raspberry Pi, and then connect the mains electric to the power switch. This make it a universal option across all models (such as the new Raspberry Pi Model A+), where using the GPIO or adding pins to the P6 header isn’t an option.
Head to Pi-Supply.com for one of these inline devices which retail for around $20 plus shipping.
Jumper + GPIO = Reset Your Pi!
With a motherboard jumper you can request the Raspberry Pi commences an orderly shutdown, the equivalent to entering
sudo shutdown –h now
with the help of a script.
Identify the GPIO pin array. On the Model A and B (Rev 2) this is found on the opposite edge of the board from the power connector, and comprises 26 pins. On the Model A+ and B+ you will find a 40 pin array occupying almost the entire long edge above the Raspberry Pi Model B+ printed text.
In each array, GPIO 3 – pins 5 and 6 – can be used to initiate shutdown. Copy this script from github and execute it on your Pi (if you’re using SSH, which you should be, copy the script from your browser and then right-click in the SSH window to copy). Make it executable with
sudo chmod 755 raspi_gpio_actions.sh then sudo ./raspi_gpio_actions.sh
With the jumper attached, the script polls the GND (ground) pin to check if anything is connected. Once the pins are connected by the jumper, the script will run and shutdown the Pi safely.
To save you running the script each time you boot your Pi, open /etc/crontab in nano and add this line:
@reboot root /home/user/scripts/raspi_gpio_actions.sh
Press CTRL+X to save and exit. This will regularly poll GPIO3 and when the device detects the jumper on the pins it will automatically shut down.
When complete, remember to remove the jumper. You might leave it attached to just one of the pins, so as not to lose it. If you don’t remove it, the Raspberry Pi will not boot correctly.
Be aware that this method is no good for situations when the Pi has crashed or frozen. It’s essentially an automated way of running the safe shutdown command, so there’s a strong chance that if the device is frozen, the script won’t run.
Give Your Raspberry Pi A PC-Style Soft Reset Switch
Adding a couple of pins to the P6 header (labelled Run on the Model B+) using a soldering iron and some fine-gauge solder designed for electronic work allows you to add a PC-style reset button to your Pi. This requires a momentary switch, which is essentially an instantaneous on/off action.
All of these components, and the connecting wire, can be purchased online or from electronics retailers. You may find that the pins can only be bought in bulk, however, leaving you with more than you need.
In this situation, and in light of the requirement for a PC-style reset button, it’s worth checking any old computers you have. The pins and reset switch seen here came from an old motherboard and a recently-disused tower. Alternatively, you might purchase a small board-mounted button for a wire-free solution.
Only the Model B Rev 2 and Model B+ Raspberry Pi have the P6/Run header. To find it on your Model B Rev 2, look for the HDMI port, where you should find two small holes a few millimetres apart.
On the B+, the header next to the display ribbon connector, near to the microSD slot, and to the right of the printed “© Raspberry Pi 2014”.
By soldering the pins to the Run header cleanly, you create a connector for the reset button. Once connected and with your Pi powered up, ensure that no action is taking place to test the button.
This video explains in full:
It should work fine. Better still, when your Pi is powered off, the reset button can be used to switch it on!
Time To Reset Your Raspberry Pi
We’ve shown you three different methods for resetting a Raspberry Pi. The inline power switch from PiSupply.com gives you the hard reset option, enabling you to switch off and back on quickly. Meanwhile, adding the jumper to the GPIO pin on compatible devices enables you to automate an ordered shutdown.
Finally, the DIY reset switch option provides a soft reset whenever your Raspberry Pi has locked up.
Be aware, however, that an inline power switch is purely for emergencies, not for everyday rebooting, for which you should use the GUI or bash command for shutting down safely.
Do you use a reset switch on your Pi? Considering trying any of these options? Let us know, and ask any questions, in the comments box below!