Posted on

RetroPie Shutdown and Startup Switch – The Easy Way

Tired of unplugging your Raspberry Pi to turn it off?

Don’t want to purchase one of those switched USB power adapters and have to shutdown your Pi from a menu every time? Do you also want an easy way to turn your Pi on?  There’s a script for that.  And you may have already seen it floating around on YouTube but there’s a lot of code you have to copy and paste to get it working.  So, want a push button that can turn on and safely shutdown your Pi, and an easy way to get the software working?  Well, here it is –

Hardware setup:

You will need to connect a momentary switch from pin 5 (GPIO 3) to pin 6 (GND).  Pin 6 tends to be the most convenient ground, but it doesn’t actually matter which one you use – pins 6, 9, 14, 20, or 25 will all work.  See the pinout if you’d like to use a different ground pin.

Raspberry Pi Pinout (all versions)

Pi 3 Connections:

Raspberry Pi 3 Reset Pins

Pi Zero Connections:

Raspberry Pi Zero Reset Pins

You can use pretty much any momentary switch that is normally open.  You can even use a reed switch for a magnet activated switch to avoid drilling holes in your case!

On Raspberry Pi 3, you will need to connect pin connectors (Dupont connectors) to the switch wires, or find a switch that already has them (just an example, not a recommendation).

If you need to add pin connectors to your switch, you can solder/splice on female Dupont wires.

Or, (especially if you plan to do multiples), you can crimp your own connectors with a kit like this.  While, it is *possible* to crimp those connectors with some regular pliers, it’s not really ideal so you’d also want to get a crimping tool.

Software setup:

Once you have your switch connected, you will need to install a bit of software to allow the switch to shut down your Pi (pressing the switch while the Pi is shut down will turn it back on without any software.) Your Pi needs to be connected to the internet to download the install script and packages.

Hat tips to Barry Hubbard who I believe is the originator of the Python script that makes this work, and to ETA Prime for creating an awesome how-to video that’s popularized this mod.  I used ETA Prime’s video to do this initially and realized that the process was more complicated and error prone than it needs to be.  So, I created a script that automates the entire software setup.

There are two ways you can run the setup script: using a keyboard plugged into your Pi, or over a network terminal session using your computer. Using your computer over the network was the preferred way to do this using the ETA Prime instructions due to the amount of copying and pasting required.  However, it’s might be easier to use a keyboard (at least in the UK) for this method unless you’re already set up to connect over the network.

Keyboard Method (UK):

  1. Press the start button on your game controller and exit emulationstation to get to the shell.
  2. Type the following and press enter:

curl | bash

That’s it! You’re done.

(Skip to testing section)

Keyboard Method (US):

Some distros including RetroPie have the keyboard layout set to GB by default, so there’s no way to type the | symbol on a US keyboard. So you can do this instead:

  1. Press the start button on your game controller and exit emulationstation to get to the shell.
  2. Enter the following commands (press enter after typing each line)

curl --output

sudo chmod +x


That’s it! You’re done.

(Skip to testing section)

SSH/Network Method:

Make sure your Pi is connected to the same network as your computer either via Wifi or Ethernet. For Pi Zero you will need a WiFi dongle.

Using Windows:

  1. Download putty.exe to your desktop (if you have a relatively modern computer, you probably want the 64-bit version)
  2. Start putty
  3. Enter ‘retropie’ as the host name, make sure SSH is checked, and click open.
  4. If you are presented with a security alert about the server’s host key, click yes.

Using Mac/Linux:

  1. Open the Terminal application.
  2. Type ‘ssh retropie’ and press enter.

Host not found / other error?

If you get an error like ‘host not found’, you may need to use the IP address vs the host name of the Pi.  To get the IP address: in RetroPi select the RetroPi channel and select Show IP.  Use the IP in place of ‘retropie’ in the previous instructions.

Once you’ve connected:

  1. Once you’ve connected to the Pi via SSH, you will be prompted for a username and password. The username is ‘pi’ and the password is ‘raspberry’ (all lower-case).
  2. You should now be at a shell prompt. Copy and paste the following command and press enter:

curl | bash

That’s it! You’re done.


Now the shutdown script should be installed and set up to run every time the Pi boots.  To test it out, press the switch.  The Pi should shut down.  Press the switch again and the Pi should boot up.


If your Pi didn’t shut down, shut it down manually.  Press the switch.  If your Pi doesn’t start up, there’s something wrong with your switch/wiring/connection.  If it does start up, wait for emulationstation to load and press it again.  If it doesn’t shut down, there’s something wrong with the software setup.  A good place to get help at that point would be the RetroPie gaming group on Facebook.


Copyright © 2017

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and limitations under the License.