Trybotics Logo

Raspberry Pi Mobile Gaming Device

DESCRIPTION

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!

Description:

SKILLS

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...)

PARTS

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 tactile push buttons - (round: https://www.adafruit.com/product/1009 and square: https://www.adafruit.com/product/1010)

An assortment of wires, resistors, and other small components

Perf board

1/4" wood and 1/2" wood for building the case

TOOLS

Soldering Iron

Needle Nose Plier

Wire Stripper

A Soldering Station/Helping Hand may be useful also.

Drill Press

Band saw/scroll saw

Table Saw

Belt sander

Dremel Tool

SOFTWARE

RetroPie (https://retropie.org.uk)

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. If you are running Windows, you will need to install PuTTY (https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html) in order to SSH into your Raspberry Pi.

Description:

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!

Controller Wiring

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!

Power Wiring

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.

Indicator LEDs

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.

Description:

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 on a piece of paper or just leave this menu open for now.

On your computer, you will need to SSH into your Raspberry Pi.

If you are on Windows, download, install and open PuTTY (link in parts list) and set the "Hostname (or IP address)" box to your Raspberry Pi's hostname, then click "Open" to start the session.

On Mac and Linux, you can simply open a terminal and type

$ ssh pi@hostname

replacing "hostname" with the IP address you got on the Raspberry Pi. Note that the $ is not typed into the terminal, it just means that this is a new terminal prompt.

Next, enter

$ nano /home/pi/Controller.py

and paste the contents of the the Controller.py file from Github into it. Controller.py is the python script that handles all the control inputs, such as joysticks and buttons.

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 hit CTRL-X (Windows) or CMD-X (Mac) and then Y (no CTRL/CMD) to save. This sets the Controller.py script to launch at boot.

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 or Configuration / Tools -> emulationstation and choose the option to Clear/Reset Emulation Station input configuration

Next time you reboot, your USB controller won't be set up anymore, but you will be able to set up your custom controls at that point.

At this point, you can load your ROMs onto the Raspberry Pi. There are many different ways of doing this, and I found these videos the most helpful:

Through your Browser - This option also gives you easier access to some other things on you RetroPie installation, since it gives a web-based GUI for many of the tasks that normally are done through the terminal or the RetroPie text-based GUI.

Over your Network - This option allows you to transfer ROMs from within your computer's file browser, making it easier to navigate to your files. It also allows you explore and edit some shared folders on RetroPie, such as BIOS, splash screens, and config files.

Using both options will allow more control of your RetroPie installation, but only one is needed to transfer ROMs. Pick the one that best suits you.

Description:

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.

Description:

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).

Description:

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.

Description:

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!

Description:

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.

Description:

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 and/or glued to the mounting holes in the breakout boards. I used Gorilla super glue, as it bonds quickly and is able to join wood and perf board easily. One joystick breakout board had to be trimmed down on one side with a belt sander 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.

Description:

Now that the hardware is done, you can finish setting up the controls in RetroPie. First, plug in a 5v 2.5A power adapter, or any official Raspberry Pi power adapter, as your battery may not be charged yet. Make sure you have at least 2.5A if your Pi is on while you are charging it, as power is divided between the PowerBoost charging circuit 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 game and testing it out!

Description:

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 (I believe) 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 :)

- Holes for charging status LEDs. The charging indicator LEDs on the PowerBoost tell whether the battery is charged or not, and I forgot to drill a hole so that they can be seen. A good place would probably be the back of the case behind the PowerBoost, or on top above the LEDs.

- Back panel removal holes. The back panel on mine is kind of a tight fit, so some holes that would allow you to pull it out with your finger might be a good idea.

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. 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!

Description:


YOU MIGHT ALSO LIKE