While there are lots of great resources available online to help setup and create your own retro-gaming console, much of this information is scattered across a bunch of forums and websites. This is an attempt to bring much of what you need to know about the process together in one place. Designed to cover the basics and then some to help you get going fast on your own console.
This guide goes over setting up the RetroPie emulator on a Raspberry Pi, creating a functional power button and cooling fan based on CPU temperature using background scripts, and a number of other helpful tips I learned during the build. This is NOT a guide for every advanced setting for RetroPie, but a guide that covers all the essentials for setup.
Note: This is a relatively long guide but you do not need to complete all the sections. If you are only interested in getting up and running playing your favorite games, you only need to worry about the first section
...And if you're already familiar with RetroPie than you can skip down to the Additional Components to spice up your systemRetroPie:
RetroPie is amongst the most popular emulation software around and is specifically built to run on the Raspberry Pi. It comes packed with a large number of console emulators for classic systems and is highly customizable, making it the go to choice for DIYers and retro-gamers. To get the most out of the software and have your system performing well, it's recommended to use the newest Raspberry Pi Model 3 B+ (referenced as "RPi" in this guide). This first section will be a walk through of how to get RetroPie running on your device and how to properly configure essential settings.
Installing RetroPie:
Choose a micro SD card that is 8GB or higher to accommodate both the RetroPie OS and the games that will be loaded on it. Most games from older consoles take up virtually no space (in the kB range), but some of others like the PS1 and N64 systems that you can emulate take up as much as 250 MB per game. So plan ahead when picking a size so that you don't run out of storage.
1. Start by downloading the latest version of RetroPie.
2. Flash to SD using etcher.io.
- RetroPie is an.img file so it can't just be dragged and dropped onto the SD card like a text document. Etcher helps easy format and write the.img file onto the drive (this is not exclusive to RetroPie, any OS that you want to run on the RPi must be written this way).
3. Insert SD in Raspberry Pi
4. Power on
With the RPi plugged into a monitor you'll see the boot sequence beginning with lines of text showing the system working. The first time you boot up the system it will take some time to setup, after this initial time subsequent boots will be much quicker. Once this is done, you'll be shown a screen for configuring a controller, for the rest of the setup you're going to want a keyboard to navigate and type in credentials.
After you've setup the keyboard (see later section if unsure how) and pass this screen you'll be dropped into emulationstation. This is where all the game consoles that you load onto the system will appear, but before playing games there are still a few steps in setup that you may want to do.
Connecting to WiFi:
To connect to wifi, start by navigating to the RetroPie configuration from the emulation-station screen (at this point without any games loaded this should be the only option available). Once you have selected RetroPie, you'll see a new screen with more advanced setup options. WiFi is located at the bottom of this list.
After selecting WiFi there will be another, not so pretty, option menu. From here you will select “Connect to Wifi Network”, choose your network, and enter the password. You should now be connected to your WiFi network.
Note: While not always necessary (as in this case), it is generally recommended that you reboot your system after making changes within settings as not all changes will go into affect until the next boot sequence.
Updating RetroPie:
If you've just downloaded RetroPie from the website, your system is most likely already the most recent version. However, it doesn't hurt to check this by running the update script. This is also important to know so that you can periodically check in and ensure that you are running the latest version. Updating is an easy process, but does require that you are connected to WiFi.
1. Enter RetroPie Configuration menu
2. Select "RetroPie Setup"
3. Select " Update RetroPie-Setup Script"
- If there is an update, this may take a few minutes to download and install
4. Reboot the system
Autologin:
One annoying thing that you may or may not run into when booting up RetroPie is being prompted for login credentials. Obviously you don't want to have to deal with this every time you turn on the console and you likely won't want to have to keep a keyboard around just to type this in. There's an easy way to fix this by changing the settings to "Autologin".
1. Access raspi-config
:
- either through RetroPie configuration,
- or entering
sudo raspi-config
in command prompt (open command prompt by pressingF4
on home screen)
2. Select "Boot Options"
3. Select "Desktopp/CLI"
4. Select "Console Autologin"
Note: The default login credentials for RetroPie are; Username: "pi", Password: "raspberry"
InstallingGames:
Now that Emulation Station up and running, it's time to load games onto the system. Games are downloaded as ROM (Read Only Memory) files that differ across consoles. ROMs can be downloaded from a lot of different websites, a quick google search will turn up pages of them, not every site carries every console so a bit of hunting is sometimes involved to find certain games. There's two primary ways of transferring game ROMs onto the RetroPie; USB and SFTP. The following steps come from the RetroPie GitHub.
USB Stick:
0. Ensure that your USB is formatted to FAT32
1. First create a folder called retropie
on your USB stick
2. Plug it into the pi and wait for the green LED to finish blinking
3. Pull the USB out and plug it into a computer
4. Add the roms to their respective folders (in the retropie/roms
folder)
5. Plug it back into the raspberry pi
6. Wait for green LED (next to red power LED) to finish blinking
7. You can now remove the USB stick.
8. Refresh/reboot emulationstation by pressing F4
, or choosing quit from the start menu
SFTP:
0. Enable ssh communication within RetroPie
- Navigate to the RetroPie configuration area.
- Select
raspi-config
- Select
Interfacing Options
- Select
SSH
- Choose
Yes
- Select
Ok
- Choose
Finish
1. Download the SFTP program of your choice, FileZilla is a good one and works on both Mac and Windows.
2. Connect to the RPi by entering the IP address and user credentials (default Username: "pi", Password: "raspberry")
3. Drop files in ~/RetroPie/roms/$CONSOLE
directory where $CONSOLE
is the desired console (e.g. snes
)
4. Refresh/Reboot emulationstation by pressing F4
, or choosing quit from the start menu
Once the system has been rebooted you will now have access to the new games you transferred over.
Note: Don't worry if you are adding a game for a console not currently shown in emulationstation, once the system reboots, any console that has ROMs in its system files will become available.
Keep in mind that while the RPi 3 B+ has a decent amount of horsepower for its size, it can't handle every console. The rough cutoff in terms of console generation is with the N64 and the PS1 where the RPi can run certain games well and others not so much. This means no GameCube/PS2/XBox or later. If you've chosen to use a RPi Zero for its compact size, then you are further limited by at least one generation. There is a way to play certain PC games, but it's a bit of an involved process and the gameplay isn't great.
Choosing a Controller:
Many people who make retro systems like to have a controller that matches the console they're emulating, you can find USB versions of almost any controller you can think of on amazon. However, the best solution to use for all games/systems is to pick a modern console controller, like the PS3/4. These controllers have enough buttons and sticks to cover any older console's games, just keep in mind that you have to setup the inputs for whatever controller you choose so don't forget what button does what (e.g. "circle" on the controller may correlate to "A" for the emulator). This configuration happens the first time you power up RetroPie with a new controller input from USB (you can reconfigure later from settings if you want to change something).
Another great feature of the RPi is being able to connect to a controller wirelessly through bluetooth. This can help reduce the number of wires you have running from the console and cut down on the power usage that comes with wired controllers. Here's more information on ways to connect a PS4 controller from the RetroPie Github (information about other controllers can also be found here).
Later on I'll be talking about the power consumption of the console and its peripherals, be sure to check out that section before making any final decisions on purchasing controllers.
Configure Controller:
Setting up a controller is pretty straightforward, you will be prompted on screen to assign buttons on the controller to specified inputs. All you need to do is press the button on your controller that you want to represent the input/button that is highlighted on the screen. Joysticks and D-Pads are also configured here, just push in the desired direction when prompted.
This is why having a newer controller can come in handy because you can assign more buttons that can be used during the emulation of different systems. Once a gamepad has been configured, you won't have to set it up again and RetroPie will automatically identify it when plugged in.
The gamepad pad is also used to both play games and navigate emulationstation aided by the use of Hotkeys. These Hotkeys give you access to the emulation features within the game itself and are important to keep in mind. The most important ones are the "Exit", "Save", and "Load" actions. "Save" will create a save state that can be resumed at any point in time by using "Load". This means that where traditionally you wouldn't have been able to save, like mid level, you can jump right back in whenever (like when first booting up or jumping right back to before the boss battle without having to fight your way back through the stage). Games like Pokemon that have a save option in their menu DO function correctly, but it still doesn't hurt to also do a save state.
"Exit" will take you back to the main emulationstation menu, be sure to save before using the "Exit"hotkey as any unsaved data will be lost upon exiting. Be sure to remember exactly which keys are which to avoid any frustration from; screwing up a save, loading backwards in progress, or exiting and losing data. The following is a chart that you can you for reference:
Play:
At this point the heart of the project is complete, you can play games as is right from the RPi without any problems. But this isn't a console, it's small exposed board with wires/cables coming out of it. The rest of this guide will be on additional components to add to the system to create a more complete console.
Additional Components:The following sections are for those who are interested in a more complete finished console. This will cover power management, adding a power button and cooling system, and designing/choosing a case for the system.
Power Supply:The power supply I've chosen for my project is actually 5V/3A, not the 5V/2.5A that is recommended for the Raspberry Pi Model 3 B+. The reason for this is the number of peripherals that will be running off of the RPi's power supply. While the fan does draw a small amount of this power, it's the controllers/keyboards used for playing games that sap more power.
There's a great database contributed to by RetroPie gamers (started by "suprjami") that has power usage for the majority of popular controllers: Game Controller USB Power Database. It's a good thing to keep in mind if you're planning on having multiple people playing simultaneously. It's also important to note that these are for the max power, meaning that the controllers aren't necessarily constantly pulling that much power. This is affected by things like controller rumble, or for controllers with batteries, whether or not they are charging. As mentioned in an earlier section, there is a way to connect certain controllers via bluetooth which can help cut down on total power usage as well.
It's important to always power-off the console properly to prevent the SD card from becoming corrupted. Many people who are newer to raspberry pi (and even those who aren't) tend to pull the plug to power off the device, I know because I was guilty of this. It's easy to forget because of it's small size that this device is a computer, and like any computer, disrupting it's power supply during use can permanently damage the system. The last thing you'd want is to lose all the data from however many games you've loaded onto the console.
In addition to having this safe-shutdown, we also want to be able to turn the console back on without having to unplug and plug in the power cable. This is the simpler of the two functions because the Raspberry Pi is already designed to be "woken up". When shutdown from within the OS, the RPi will enter a sort of "sleep" state. In order to boot the system back up, all you have to do is bridge/short pins 5 and 6.
Since pin 5 is a GPIO Pin, we can use this pin for our shutdown button as well. The way this works is by creating a python script running in the background monitoring for a button push. When the program registers that the power button has been pressed, it will perform a safe shutdown, then the same button can be used to power the system on by bridging the pins. You can use any momentary tact button that you want for this, I found a nice LED power button on Adafruit that I liked (link above under things), just don't be stupid like me and accidentally fry the LED on the first one...
You can find great resources for how to add power buttons on the forums, reddit and youtube. I did find a video that does a complete walkthrough of the process so that you don't have to piece together the bits of information you find elsewhere. I'll include the video below this written guide if you're more comfortable directly following along with someone.
Step 0: Accessing the command prompt
The process for this is a simple one, but does require use of the command prompt which can be intimidating to those who aren't used to it. There are two ways of accessing the command prompt for RetroPie; by plugging in a keyboard to the RPi and pressing F4
while on the home screen, or by using ssh communications from a separate computer on the same wifi network. The quicker of the two ways will be through ssh because you can copy and paste all of the following commands without having to worry about mistyping anything. In order to do this, you will still need RetroPie to be running and have the IP Address of the RPi on your network which you can find from the settings page.
Step 1: Installing Dependencies
sudo apt-get install update
sudo apt-get install python-dev
sudo apt-get install python3-dev
sudo apt-get install gcc
sudo apt-get install python-pip
Step 2: Installing RPi.GPIO
Download and decompress package:
wget https://pypi.python.org/packages/source/R/RPi.GPIO/RPi.GPIO-0.5.11.tar.gz
sudo tar -zxvf RPi.GPIO-0.5.11.tar.gz
Move to the new directory:
cd RPi.GPIO-0.5.11
Install the RPi.GPIO module:
sudo python setup.py install
sudo python3 setup.py install
Step 3: Create Shutdown Python Script
Create directory for new script:
mkdir /home/pi/scripts
Create and begin editing python script titled "shutdown.py":
sudo nano /home/pi/scripts/shutdown.py
Copy and Paste the following code into the newly created file:
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import subprocess
PIN = 3 # Pin 5 on the board is GPIO 3
GPIO.setmode(GPIO.BCM)
GPIO.setup(PIN, GPIO.IN, pull_up_down = GPIO.PUD_UP)
oldButtonState1 = True
while True:
buttonState1 = GPIO.input(PIN)
if buttonState1 != oldButtonState1 and buttonState1 == False:
subprocess.call("shutdown -h now", shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
oldButtonState1 = buttonState1
time.sleep(0.1)
Save this file by pressing CTRL X
to save, then Y
and Enter
to accept.
I'm not sure how necessary having both conditionals for the if statement is, but the code works perfectly so I'm not going to mess with it.
Step 4: Running Script on Startup
Open file to add to start up procedure:
sudo nano /etc/rc.local
Add following line, be sure to include the "&" since the program is an infinite loop, the process must be forked:
sudo python /home/pi/scripts/shutdown.py &
This should be located in the file as follows:
...
fi
sudo python /home/pi/scripts/shutdown.py &
exit 0
Again, save this file by pressing CTRL X
to save, then Y
and Enter
to accept
Step 5: Reboot the System
sudo reboot
Once done, you will be able to safely turn the console on and off with a button connected to pins 5 and 6. If you don't have a button yet, or just want an easy way to test the system, grab a single jumper cable. Attach one end to to pin 5 then briefly connect the other to pin 6 and remove it, the system will shutdown. Once the RPi is asleep (wait for at least 5 seconds on black screen), bridge the pins again briefly and it should wake up.
As mentioned before, here is the video with the same step by step guide. This guy puts up a lot of great guides that can help with your RetroPie build, especially for arcade style systems.
If you choose a power button that has an LED, or just want an LED indicator light for when the RPi is on/off somewhere on the console then you can do so without any additional code. The easiest way to do this is by activating serial communication from the raspy-config settings menu. Enabling serial communication will cause Pin 8, UART TX, to turn on when the RPi powers up and turn off when shutdown, unlike the 3.3V and 5V pins. Most LED's can be run without a resistor with this pin, but I used one to be safe and to cut down on the brightness a bit.
The Raspberry Pi will begin to heat up quickly while being used for emulation during extended periods of time. To prevent against damage, the RPi will automatically try to regulate itself by operating at a lower level (I believe dropping to ~1.0GHz). So in order to protect the board and ensure that the game emulations don't suffer from performance issues, a cooling system can be added. Generally I use a simple heat sink, but because the RPi for my build is going to be completely enclosed, I've decided to use a small fan (you could use both if you really wanted to but it would be overkill).
Circuit:
We don't want the fan to be running after shutting down the system, but if the fan is connected directly to the 5V pin and the RPi is plugged in, it will run when the system is both on and off. We can fix this with a transistor and another GPIO pin. Additionally, this can give us the ability to turn the fan on and off in response to how hot the CPU is by checking the system with a python script. That way the fan only runs when the CPU is hot enough to justify it.
Code:
We can either create a new script to run at startup, or add onto the already existing "shutdown.py" script we've made. I'll be making a new script just to keep the subprocesses separte and easy to manage.
Step 1: Create Fan Management Script
Create and begin editing python script titled "fan.py" in the same directory as the shutdown button:
sudo nano /home/pi/scripts/fan.py
Copy and Paste the following code into the newly created file:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
from time import sleep
import RPi.GPIO as GPIO
PIN = 18 # Whatever GPIO pin you are using
MAX_CPU_TEMP = 40 #C
# Setup
GPIO.setmode(GPIO.BCM)
GPIO.setup(PIN, GPIO.OUT)
# Functions
def get_cpu_temp():
readout = os.popen("vcgencmd measure_temp").readline()
temp = (readout.replace("temp=","").replace("'C\n",""))
return float(temp)
def fan_on():
GPIO.output(PIN, True)
def fan_off():
GPIO.output(PIN, False)
# Main
while True:
cpu_temp = get_cpu_temp()
if cpu_temp > MAX_CPU_TEMP:
fan_on()
else:
fan_off()
sleep(10) # Checks temp every 10s (Change as you wish)
Include schematic for button/led and fan connected to RPi pins.
Step 2: Running Script on Startup
Open file to add to start up procedure:
sudo nano /etc/rc.local
Add following line, be sure to include the "&" since the program is an infinite loop, the process must be forked:
sudo python /home/pi/scripts/fan.py &
This should be located in the file as follows (shown with both power button and fan scripts):
...
fi
sudo python /home/pi/scripts/shutdown.py &
sudo python /home/pi/scripts/fan.py &
exit 0
Save this file by pressing CTRL X
to save, then Y
and Enter
to accept
Step 3: Reboot the System
sudo reboot
Design:There are a lot of cool custom gaming systems, many of them are either inspired by, or designed to look like the original classic consoles. Others take a different approach and go for something entirely unique. This is the most creative part of the process for creating your own retro-gaming console: deciding how you want it to look and feel. Here's a few examples (the two smaller ones use the RPi Zero in place of the 3 B+):
However, if you're not looking to go all out like these, having any case for the RPi is better than leaving it exposed. You can find a lot of inexpensive cases on Amazon if you want something basic, or it you are interested in something a little more custom and have a 3D printer, you can find ever more designs on Thingiverse.
I decided to design my own case on Fusion 360 and print it out myself. I like having a console feel with controllers in the front and power/audio/video in the back. So for that reason I went to the trouble of moving the micro USB power and HDMI ports to the back of the case. To make that work, I picked up 90 degree extension cables to attach to the RPi and feed to the rear of the case. There's no need to do this, but in my opinion this feels more like a finished product and it gave me the chance to design in the fan and power button so they fit perfectly.
For the fan cooling; I placed the vents on the bottom of the case and put the fan blowing out of the top. This helps create more uniformed cooling with air flowing over the entire board and reduces the amount of dust that gets inside the case. If you do something like this just make sure that the vents aren't blocked, I added rubber feet to the bottom of the case to keep it secure and make sure there's airflow. The power button was placed on the front face to the right of the USB ports.
Assembly:Some pictures of it all coming together.
Since I glued the fan in place to reduce noice from vibration, I used the hardware that it came with it to attach the top and bottom of the case together.
I'm really happy with how it came out and think it looks great for the entertainment setup I have. I'll include a link to the CAD files below if you want to follow the same build, just make sure that you have the right hardware (fan and button).
There is still a lot more that can be known about RetroPie, like adding additional emulators, running PC games, custom themes, or setting up arcade button controls, that I've left out of this guide. Those are more project specific, whereas these can apply to most.
If there's something you'd like to have added/clarified or if there's an error somewhere, just let me know.
...one last thing: I have a website now and would love if you took a minute to check it out, thanks! SamsWorkbench.com
Comments