Introduction: Raspberry Pi Mobile Gaming Device
Have you ever wanted to be able to play classic video games on the go, but weren't sure where to get a device capable of running old games, or they were just too expensive? Then make your own!
This is a documentation on the building of my Raspberry Pi Mobile Gaming Device, inspired by the Nintendo Switch. The cost is just under $200, and is capable of running many older games with the use of RetroPie. RetroPie has over 30 emulators built in, so running older games is a breeze, so long as you have the ROMs!
There were many things I would have done different in this project, and I will try and share that with you in this tutorial. That way you can learn from my mistakes without having to make them yourself.
Hopefully you can use the instructions in this tutorial to create your own Raspberry Pi gaming device. If you do please tell me by clicking "I Made It!" at the end of the Instructable.
Also, if you like this project, please vote for it as it is in the Game Life contest. Thanks!
Step 1: Parts List
You will need to be handy with a soldering iron, know basic Python, and have some grasp in woodworking.
The ability to destroy video games is a must too (I'm still working on that though...)
1x Raspberry Pi 2 or 3 - $35
1x Raspberry Pi Official 7" Touchscreen - $75
1x Micro SD card (8GB minimum, you will probably want more though for your ROMs!)
1x Lithium Ion Battery Pack - 3.7V 4400mAh - $19.95 (https://www.adafruit.com/product/354)
2x Analog 2-axis Thumb Joystick - $5.95 (https://www.adafruit.com/product/512)
1x PowerBoost 1000 Charger - $19.95 (https://www.adafruit.com/product/2465)
1x MCP3008 - 8-Channel 10-Bit ADC - $3.75 (https://www.adafruit.com/product/856)
1x Adafruit Trinket - $6.95 (https://www.adafruit.com/product/1500)
4x 3mm LEDs
An assortment of wires, resistors, and other small components
1/4" wood and 1/2" wood for building the case
Needle Nose Plier
A Soldering Station/Helping Hand may be useful also.
Band saw/scroll saw
All of the code and Fritzing schematics are available in this Github file
You will also need another computer to load RetroPie and ROMs onto your Raspberry Pi. This computer will need Etcher.io, Win32DiskImager, or another application that can write RetroPie to an SD card, along with the latest Arduino IDE.
Step 2: Breadboard Your Circuits
I began by breadboarding my circuits, to make sure everything worked out as planned.
I have included the schematics and code in the Github file at the beginning of the tutorial; however, I have made some minor changes that I forgot to document, so some things may have been different than they are now. The code can be used as a starting point for your project, but I highly recommend at least reading through it to understand it, and changing it to meet your specific needs or make it better.
All of the controls are wired to 3.3v, connecting to 5v may damage your Raspberry Pi!
There are 12 control buttons total. 4 for A/B/X/Y, 4 for the DPAD, one for each Start and Select, and two shoulder buttons. You might be able to have 4 shoulder buttons depending on space, but most RetroPie games that require shoulder buttons only require two (I think...).
The buttons are wired on one side to 3.3v through a 10k resistor, and on the same side are connected to their respective GPIO pin through a 1k resistor. The other side is connected directly to GND (ground). If the logic is different in your circuit, make sure the logic in your code reflects that! In the code I provided it may work either way, but don't quote me on that ;)
The joysticks are wired to the MCP3008 ADC (Analog to Digital Converter). There are 8 channels one one side, and the SPI interface on the other. Make sure you are connecting the outputs from the joysticks to the correct side of the ADC! The joysticks' X, Y and SEL (button select) are all connected to the ADC. The SEL pin is not analog, but to save on GPIO pins, I connected them to the ADC. I did wire a resistor from the SEL pins to 3.3v, as the output is set to a floating value when not pressed, then shorted to ground when pressed.
The ADC is connected via 4 pins to the Raspberry Pi, but certain pins are not required (as far as I know. The pins in the schematic were tested and worked fine, along with a few others). Like I said above, make sure you code reflects your hardware!
You will need to first upload the code for the Trinket from the Arduino IDE. Open the TrinketRPi.ino file in the Arduino IDE, select your board and port from the tools menu, and hit the upload button.
The PowerBoost's 5v output is connected directly to the Raspberry Pi 5v GPIO pin and the Touchscreen's 5v pin, and the ground from the PowerBoost is connected to the Pi and Touchscreen's ground pins. The trinket is powered from the Raspberry Pi's 3.3v GPIO pin.
The Adafruit Trinket is used to control power. Pin 0 on the Trinket is connected to GPIO 15 (not physical 15) on the Raspberry Pi, and pin 2 on the Trinket is connected to the EN pin on the PowerBoost. Along with that, a power button is wired between BAT and EN on the PowerBoost. When this button is pressed and held for about 5 seconds (the time it takes for the Trinket to start), everything is powered on. When released, the Trinket holds pin 2 HIGH (connected to EN pin on the PowerBoost), keeping power going to the system.
The power button only works as an ON switch, as I was not sure how to make a circuit that would let it act as both on and off. The Pi can still easily be shut down from the software though!
When the Pi starts, pin 15 is set to HIGH (Controller.py) to notify the Trinket that it is on. When the Pi is powered off in any way, pin 15 goes LOW, causing the Trinket to hold power for ~20 seconds, then turning off power completely.
I am sorry to say that I made some changes to this that are now buried in an enclosure, and I am not sure what I did as this project was made a while ago. This layout should work, but please test it before cramming it in an inaccessible place!
The PowerBoost's BAT pin is connected to the ADC to read battery level. A 6.8k resistor connects the BAT pin to the ADC channel, and another 10k resistor connects the BAT pin to GND. This allows the ADC to get battery output voltage, and approximate the battery level. When charging, the battery output will be 5v, so there isn't any way to know battery level while it is charging with this setup.
If you would like, you can connect VBUS on the PowerBoost in the same way as BAT; this allows you to know if the battery is charging.
The four indicator LEDs allow you to see things such as battery level, volume or display brightness. The code is only set up for battery level at the moment.
Each 3mm LED is connected from a GPIO pin, through a 100ohm resistor, and back to ground. My LEDs are green, make sure to choose the appropriate resistors for other colored LEDs, as they have different power requirements!
Thats it for wiring! After you have tested your wiring on a breadboard, you can start making a more permanent circuit.
Step 3: Set Up the Software
For loading RetroPie onto the SD card, you will need an application such as Etcher.io (recommended) or Win32DiskImager, and the RetroPie operating system from the link at the beginning.
To use Etcher, first insert your micro SD card into your computer. Open Etcher, and click "Select Image". Navigate to the folder where you downloaded RetroPie, select it, and click "Open". Next, click "Select Drive", and select your SD card from the list. Make sure you select the correct SD card, as it will erase it! Click "Flash" and wait it to finish. It will automatically eject the SD card once done, so it is safe to remove if from your computer.
If you don't have a Raspberry Pi 3, you will need a WiFi dongle. A game controller is helpful at this step, but only a keyboard is required. Insert your SD card into your Raspberry Pi, connect it to a monitor (the touchscreen works well) and connect power. Once RetroPie boots, you will need to setup the controls. Select your controller/keyboard and follow the instructions. Once done, navigate to WiFi settings in the RetroPie menu and setup your WiFi.
You will also need to enable SSH. Go back to the RetroPie menu and select raspi-config from the list (I believe that is where it is at). Under interfaces, select SSH. It will ask if you would like to enable SSH. Select Yes.
You may have to reboot your Pi now. Once it is rebooted, go back to the RetroPie menu. I believe there is a IP address or Hostname option that will tell you the Raspberry Pi's IP address. Copy this down or just leave it at that menu.
On your computer, you will need to SSH into your Raspberry Pi. If your on Windows, you will need to download an application such as Putty. On Mac and Linux, you can simply open a terminal at type
$ ssh pi@<hostname>
replacing <hostname> with the IP address you got on the Raspberry Pi.
$ nano /home/pi/Controller.py
and paste the contents of the the Controller.py file from Github into it.
You will need to change the pin numbers to match those in your hardware.
Hit CTRL-X or CMD-X and then Y to save the file. Next, enter
$ sudo nano /etc/rc.local
then enter this line into the file:
sudo python3 /home/pi/Controller.py &
then CTRL-X/CMD-X and Y to save.
Next you can reset your controller configuration, so that you can use your buttons/joysticks instead of a USB game controller.
$ sudo ~/RetroPie-Setup/retropie_setup.sh
and go to Emulation Station configuration via
Manage Packages -> Core Packages -> emulationstation -> Configuration orConfiguration / Tools -> emulationstation and choose the option to Clear/Reset Emulation Station input configuration
If you reboot now, your USB controller won't be set up anymore, but you will be able to set up your custom controls later on.
At this point, you can load your ROMs onto the Raspberry Pi. There are many different ways of doing this, and the RetroPie website and Google will tell you all about it!
Step 4: Prepare Raspberry Pi and Touchscreen
For this project, space was going to be minimum, so I started by removing unnecessary components from the Raspberry Pi.
First off was the USB and Ethernet ports. The solder on these can be tricky to remove, as it has a high melting temperature. I cut off most of each port with a tin snip, and then unsoldered the leftover parts. Be careful while removing these ports, as some smaller components can be easily knocked off the Raspberry Pi (speaking from experience).
A single USB port is wired (not directly) to the Raspberry Pi's recently exposed USB solder pins. This allows it to be connected to the side of the case.
The USB power out port was removed from the touchscreen in the same way.
Next, I unsoldered the GPIO pins. I found the easiest way to do this was by first cutting off the black plastic part around the bottom of the GPIO pins. This allows you to unsolder each pin separately. I was unable to unsolder any of the ground pins due to higher melting point solder, but they can be cut shorter later on.
Step 5: Create Circuits for Controls
For this step, you will need sections of perf board to solder the buttons to. I have found that perf board with copper traces in lines between some of the holes may work better than perf board with all the holes separated. It is up to you on what you use though ;)
There will be two sets of 4 buttons in a diamond shape for the DPAD and for A/B/X/Y. I forgot to take pictures of mine while putting it together, but it shouldn't be very hard to figure out the layout. My buttons were just about touching on two of their corners each. The Start/Select buttons can be soldered to individual perf board, or you may be able to connect one to the A/B/X/Y button perf board. The shoulder buttons must both be soldered to their own individual perf boards as well.
The joysticks in my case needed to be soldered to their included breakout boards. You have probably already done this if that was your case too :)
The LEDs were soldered to a single strip of perf board, and so was the ADC.
Make sure to test wiring with a volt meter, because testing after installing everything in the case might be tricky!
You may want to wait before soldering any wires to the Raspberry Pi or between perf board sections until you know your casing layout. I didn't and it made it difficult to fit everything later on (oops).
Step 6: Creating the Case
The case is probably what took the longest on this project. The case you make will most likely differ from mine, so I am not going to give exact dimensions on anything (plus I lost the layout for the case).
The front, top and back are made form 1/4" wood (if I remember right), and the sides and bottom are made from 1/2" wood.
Begin by measuring the distance between the centers of your buttons, along with the diameter of each at the widest part of the button. Mark these measurements on the inside of the case where you are going to place them. You (almost) always want to drill from the inside of the case to the outside, as the bottom of a drilled hole will look nicer. It helps to place a scrap board behind your hole while drilling, so that it doesn't tear the board.
The joysticks holes were first drilled to the approximate size, and then sanded and used the Dremel tool on the inside to round them out so the joysticks would fit better.
The large hole for the touchscreen was measured from the metal section on the back of the touchscreen. I started by drilling a hole near one edge of where the screen would go, removed one end of the scroll saw, put it through the hole, and reattached it so I could cut the hole. A small outdone was made in the rectangular hole for the ribbon cable on the back of the screen to pass through (pictured above). I used the Dremel tool to shave a section down on the side of this hole, so the touchscreen would lay flush against the case.
The top of the case was drilled in much the same way, with rectangular holes for HDMI, A/V jack, USB port and charging port. The Raspberry Pi sits right up next to the top of the case, so that HDMI and A/V cords aren't needed. I probably should have used extenders though, as it was a somewhat tight fit.
The back of the case has six holes for ventilation purposes. These don't have any specific size or layout, so you could make a cool pattern with them! I forgot to drill a hole behind the PowerBoost's charging indicator lights, so I have to hold the device just right so I can see them through the ventilation holes. You may want to drill a small hole in the back of the case so that you can see them!
The sides and bottom of the case are notched along the edges so that they slot together, and create a pocket for the front and back to sit in.
Once you have all the holes drilled/cut, you can assemble the case. In mine, everything but the back was glued together, with the back screwing on to allow easy access to the components.
Step 7: Finishing the Electronics and Test-fitting
At this point, you should finish the electronics by soldering the remaining wires between the perf board sections. Make sure your wires are the correct length to get where they need to go. Always go for a little too long, as you can bend wires over slightly, but you can't stretch them!
Wires can be directly soldered to the Raspberry Pi, just make sure you double-check placement before making something permanent!
I found that it was helpful to create a perf board strip that had ground and voltage on it, so that each perf board section could connect to that instead of different pins on the Raspberry Pi or other sections.
Test fit holes and spacing to make sure your layout works!
Step 8: Painting
To paint my case, I chose a semi-gloss black paint that went matched the touchscreen very well. I taped off the insides of the holes so that I wouldn't get paint in the areas that would have buttons glued to them. The inside doesn't need to and shouldn't be painted, but don't worry if a little gets inside.
Step 9: Installing Components
To install the buttons, I cut small pieces of 1/4" wood which were glued to the perf board sections. These were then glued to the inside of the case in their respective spots using super glue, as wood glue makes it hard to hold in place while it dries.
For the joysticks, I made small "standoffs" using dowels and small pieces of wood, which were then screwed/glued to the mounting holes in the breakout boards. One joystick breakout board had to be trimmed down on one side to make it fit better.
The Raspberry Pi was installed in a similar fashion to the joysticks, with wooden standoffs attached to some of the mounting holes.
The PowerBoost had a small wooden block glued to the bottom, which was then glued to the side of the case.
The LEDs were simply glued directly to the case. I found out that the super glue "burned" the paint if it got on the outside when installing the LEDs, so you will want to be careful when doing so.
After connecting the battery, it was taped to the bottom of the case using double-sided foam tape, which seems to hold well.
After that, you can test that it powers on, and continue on to the last step.
Step 10: Finishing Up
Now that the hardware is done, you can finish setting up the controls in RetroPie. First, plug in a 5v 2A power adapter, as your battery may not be charged yet. Make sure you have at least 2A if your Pi is on while you are charging it, as power is divided between the PowerBoost and the Raspberry Pi. If you are charging it while the Pi is off, any charger should work. Boot your Raspberry Pi by holding down the power button for about 5 seconds. I found that mine did not boot while plugged in for some reason, so you may have to charge the battery until the green indicator light on the PowerBoost lights up (the battery is charged), and then unplug it. Once RetroPie starts, you will need to again set up the controller, only this time it will be the Python controller. Once your have set up your controls, make sure everything works by starting up your favorite ROM and testing it out!
Step 11: Final Words and Credits
Congratulations! You have completed your very own Raspberry Pi Mobile Gaming Device! Have fun playing games on the go, and showing it off to your friends!
A few things I would have done differently are:
- Using an Arduino for controls instead of wiring directly to the Raspberry Pi. There was a few times I burnt out a GPIO pin, and the Arduino has more pin protection than the Pi.
- 3D printing would have been nice for a case, but unfortunately I don't have one (yet)
- Planned the wiring better. I kind of rushed right into this project, then figured out a little late that I should have done some more planning.
Thankfully, I was able to finish this project, and I hope you have or will be able to also and learn something about woodworking, programming, or soldering.
I would like to thank Mr. Paul Fields for helping me in this project. He kindly donated his time, workshop and the wood to this project. He helped me learn more about woodworking, and was able to guide me through the process of making the case.
Thank you for reading this Instructable!
This is an entry in the
Game Life Contest