Introduction: Apple Pocket Pi - 3D Printable Retro Handheld Games Console
Introducing the Apple Pocket Pi!
This is a homemade, retro, handheld gaming console with all the buttons and shell fully 3D printable!
The design goals for this project were to build a pocket-sized handheld console which was as easy to assemble as possible whilst keeping costs low for the required functionality.
Specification
- 13.5cm Width x 5.9cm Height x 2.4cm Depth
- Raspberry Pi Zero 2 W powered
- 2.4 inch 320 x 240 SPI screen (capable of 60fps+ with fbcp-ili9341 drivers)
- 3000mAh battery (providing 6 hours+ gameplay time on a single charge)
- Synchronous 500mA charging via USB-C
- Mono audio with a low pass filter controlled by a volume wheel potentiometer
- D-pad, 4 face buttons, start and select buttons and L/R shoulder buttons
- Mini-HDMI video output, Micro USB input
- Built in Wi-Fi
- Built-in safe shutdown hardware to ensure software/OS is correctly shutdown before power is killed
- Visible LED indicators for "charging", "charged" and "low battery"
- On-screen low battery overlay
Running RetroPie this console is able to emulate a huge range of consoles to a high level (Atari, Amiga, Neo Geo, NES, SNES, Gameboy, Gameboy Advance, Nintendo DS, PlayStation etc) and even perform to playable levels with some games on more demanding systems (N64, PSP etc). A full list of all available emulators can be found here (performance will vary between emulators and different games).
Supplies
The supplies for this project can be broken down into 3 sections: 3D Printed Components, Electrical Components and Sundries. The STL files for the 3D printed components are attached as supporting files or can be found on ThingiVerse.
3D Printed Components
- Shell_Front
- Shell_Back
- D-Pad
- Face_Button x 4
- Start_Button x 2
- Shoulder_Button x 2
- Shoulder_Button_Pin x 2
- Screen_Support
- Speaker_Screw_Extender
- Pi_Screw_Guide (Not part of the final product, but used during the build)
Electrical Components
- Raspberry Pi Zero 2 W
- Waveshare 2.4" Screen
- Custom Motherboard (Full Details and Gerber Files found here - There are surface mount components (5 x Capacitors, 4 x Diodes, 9 x Resistors) on the bottom of the board which you should include as part of the motherboard assembly, the other components will be added as part of this guide)
- USB-C Breakout Board
- Oval Speaker 8 Ohm 1 Watt
- PAM8302 Amplifier
- Powerboost 500C
- Soft Tactile Button x 12(I had to buy two packs of 10)
- B103 10k Potentiometer Wheel
- SPDT Slide Switch
- Breakaway Pin Headers 0.1" (2.54mm) pitch
- 3000mAh 104060 LiPo Battery with JST connector (any 3.7v LiPo battery small than these dimensions will work too)
- High quality Micro SD Card (I used 128GB SanDisk Extreme Pro)
- (Optional) High quality 5V 2A+ USB-C Power Supply (if you don't already have one)
Sundries
- M3 x 4mm Screw x 2
- M3 x 6mm Screw x 2
- M2.5 x 8mm Screw
- M2.5 x 20mm Screw x 3
- M2.5 x 16mm Screw x 1
- M2 x 4mm Screw x 2
- Small amount of AWG 26 or thicker wire (silicone insulation recommended)
- Red 5mm LED
- Solder
- Kapton Tape/Electrical Tape (or equivalent thin insulating tape)
- (Optional) Soldering Copper Wick
In terms of tools there are only a few things that are required:
Tools
- 3D Printer (if you are printing your own shell and buttons)
- Soldering Iron
- Screwdriver with tips to match your screws
- Flush Cutters and/or Wire Cutters
- (Optional) Multi-meter (highly recommended for testing connections/avoiding shorts)
- (Optional) 2.5mm Bradawl (if your pin holes/screw holes are too tight, this can make your life easier)
- (Optional) Sandpaper (I used both 150 grit and 240 grit to clean up/smooth out the button guides in the shell)
- (Optional) Modelling Knife or equivalent (useful for removing blobs and blemishes from the printed parts)
Attachments
Step 1: 3D Printing
The first step is to print and prepare the shell for the PocketPi. This will vary slightly depending on your type of printer and choice of slicer, but for FDM printers it should be quite similar.
I used Cura as my slicer and printed all parts with a 0.2mm layer height, 0.4mm nozzle, 1.2mm wall thickness, 1.6 mm top/bottom thickness and 15% infill. The rest of the settings will depend more on the setup and accuracy of your 3D printer. I would recommend using a slower than usual print speed though if you want to get a smooth finish and accurate dimensions for screw holes.
For materials many different plastics could be used, but I chose PLA+ for the shell as it was good value and easier to print with compared to PETG whilst still providing plenty of heat tolerance for this project. The buttons were printed in TPU to give them a smoother more "rubbery" feel, although these could also be printed in PLA+ with no problems.
- Print the "Shell_Front.stl" face down to the build plate with supports enabled to allow for the bridges at the top and bottom, whilst also stopping sag on the port holes. I also used support blockers to prevent the slicer placing supports in the screw holes for the power switch (see the image included).
- Print the "Shell_Back.stl" back down to the build plate with supports enabled to prevent sag on the USB-C port hole.
- Print the "D-Pad.stl" in one of two ways. You can print it in the orientation it is saved in for an easier print, or for a better finish print it on its side and rotated 45 degrees. I also then dropped the model slightly down on the z-axis (-0.151mm) so that the bottom edges of the d-pad cross JUST touch (see the image included). This orientation will provide a much smoother finish to the surface, but may result in some distortion to the shape. No supports are needed for either printing option.
- Print 4 x "Face_Button.stl" in the provided orientation with no supports. I enabled ironing for the top layer to get a good finish on my TPU buttons.
- Print 2 x "Start_Button.stl" in the provided orientation with no supports. I enabled ironing for the top layer to get a good finish on my TPU buttons.
- Print 2 x "Shoulder_Button.stl" in one of two ways. You can print them with the large flat top of the button face down to the build plate, but this will likely result in a messy curved corner. For a cleaner finish print them in their provided orientation, but drop them very slightly under the build plate until the side of the button JUST touches (see the image included). To keep things symmetrical, you can also rotate one of the buttons 180 degrees around the y-axis, this means that the same side will have the "flat" edge once they are fitted in the case.
- Print 2 x "Shoulder_Button_Pin.stl" in the orientation provided with a good sized brim to prevent them falling over during printing (see the image included). Remove the brim after printing.
- Print the "Screen_Support.stl" in the orientation provided.
- Print the "Speaker_Screw_Extender.stl" in the orientation provided.
- Print the "Pi_Screw_Guide.stl" in the orientation provided.
Once all the parts are printed test out how the fit is for the buttons in the front shell, the pins in the shoulder button holes, and how well the two halves of the shell fit together.
Depending on the quality of the print you may find that some zits/blobs need to be cut off and some areas need to be sanded down to level them out.
The fit of the shoulder pins into their respective holes, should be snug, but not tight. A bradawl and/or modelling knife can be used to make the holes slightly larger, and sandpaper can be used to smooth/thin out the pins themselves. Make sure they fit into their respective holes in the front and back of the shell, and when the shells are joined together they are held in place (they should have a little movement inside their holes, but not enough to pop out when the shell is closed).
Ensure all the supports have been removed from the two halves of the shell (particularly the small support underneath the overhang for the left shoulder button.
To get a cleaner feel for the buttons use coarse, followed by fine, sandpaper inside the button wells for the A, B, X, Y, Start and Select buttons. It will make them much smoother when pushed if you spend some time on this step.
With that done the 3D printing if finished and it's time to move onto the electronics!
Step 2: Initial Software Setup
At least some minimal software setup should be done at this point to prevent troubleshooting later.
The one requirement is to flash RetroPie onto the micro SD card. There are detailed instructions on how to do this on the RetroPie website and I would recommend using the Raspberry Pi Imager option.
Once your micro SD has finished flashing RetroPie, I would recommend testing that everything has worked successfully by plugging the micro SD into your Raspberry Pi Zero 2 W, connecting it to a screen with a mini-HDMI cable, and powering up the up by plugging in a 5V power supply with a micro-USB connector. If you manage to get RetroPie to boot successfully then you can shut everything down, remove the micro SD card and set it aside for now.
OPTIONAL: In order to reduce potential issues further down the build process it might be useful to do a more thorough software setup at this stage which will allow you troubleshoot problems and test more during the build phase.
The additional software which is worth setting up would be the fbcp-ili9341 drivers for the screen, necessary changes to the GPIO modes and boot config to enable PWM audio and setting up the safe shutdown script.
The downside to doing this now is that you will need to solder temporary headers on the daughter boards to actually test these components, or you can just follow the software setup instructions without testing and everything works as expected during the build.
If you want to do these additional stages now then go to Step 20: Final Software Setup
Step 3: Preparing the Screen
The 2.4" TFT from Waveshare is a great value small screen for this project, but it does have one issue for this project which is the PH2.0 8 Pin connector (small white port shown in the first image). We will be using the pin holes to connect to this project, so this port provides no value and due to the tight clearances in this project it has to be removed in order for everything to fit together.
- The port is connected on both sides and with 8 pins along the back. Using a pair of flush cutters, cut through all of the pins (closer to the port than the board if possible). Then cut along each side of the port where you can see it is soldered to the board. At this point you should be able to lift the majority of the connector off just leaving the remains of the pins and attachment points left on the board (see the second image)
- Use a soldering iron to heat up each of the pads and remove the remains of the pins and any metal parts left on the attachment points.
- To get a really clean finish using soldering wick to remove as much solder as possible until the pads are all as smooth as you can get (see the third image).
- To protect against possible short circuits use a piece of Kapton tape to cover all the pads.
At this stage it is also a good idea to add two short (3cm or 4cm) pieces of wire to the RST and BL pinholes of the screen board:
- Cut two lengths of wire down to around 3cm or 4cm and strip a couple of millimetres of insulation off on both ends.
- Tin both ends of each wire.
- Push one wire through the RST pin hole, and the other through the BL pin hole on the bottom of the board (the side with the pin labels).
- Solder these wires to the board from the top side.
That's the screen all ready to go, so now it's time to start working on the motherboard!
Step 4: Attach Tactile Buttons
Take 10 of the soft tactile buttons and push them through the front of the motherboard in their labelled slots - UP, DOWN, LEFT, RIGHT, A, B, X, Y, START and SELECT. The legs should hold them in place, but double check they are all as flush with the board as possible.
Turn the board over and solder all 4 legs of each of the 10 buttons.
Using flush cutters cut off the legs of all the tactile buttons as close to the surface as board as possible.
With that out the way its time to connect the Raspberry Pi Zero 2 W to the motherboard!
Step 5: Solder Raspberry Pi Zero 2 W to the Motherboard
The Pi is soldered directly onto the motherboard with no pin-header, so the two boards are touching. This can be a slightly tricky soldering job, but once you get the hang of it, it's not too bad.
- Place the Pi Zero 2 W on the front of the motherboard and line it up with the outline shown.
- Take the 3D printed "Pi_Screw_Guide" and align it on the back of the board so the screw holes line up with the Pi, and the pin holes are NOT covered.
- Screw two M2.5 screws (length doesn't really matter as long as they are longer than around 6mm, so feel free to use any of the other permanent screws that are used later in this project) going from the Pi, so that they pass through the motherboard and bite into the screw guide. Tighten them up so that the Pi is flush with the motherboard, but don't tighten them so much that either the Pi or the motherboard is bending/warping.
- Double check that everything is aligned, make sure the Pi matches up with the white outline on the motherboard (it should be just visible around the edges) and make sure you can see straight through the Pi GPIO pin holes and the motherboard pin holes (holding the boards up to a light makes this easier to check).
- The technique for soldering the two board together is to lay your soldering iron just into the Pi pin hole for a few seconds to heat it up, melt a fair but not excessive amount of solder into the hole and then push the soldering iron down into the hole for 3 or 4 seconds before quickly pulling it out. If done correctly you should see the solder settle down into the hole after you remove the iron. This is a great video by Wermy which shows and describes this process with more detail.
- Using this technique solder all 40 Pi GPIO pin holes to the motherboard and the finished product should look similar to the two images included.
- Check how clean the pin holes are on the bottom of the motherboard and if there is excess solder poking out below the hole the use a soldering iron or soldering wick to get these as flush as possible.
- It is very important during this stage to check continuity of all the connections being made, and to ensure that no shorts have been made between any adjacent holes (be aware that pins 2 and 4 will show continuity as they are both 5V supplies, so don't consider this a short). Use the spread sheet image attached you should be able to check each pin and ensure it connects to the correct output (the audio connections are harder to check for continuity as they connect to components on the rear of the board for the low pass filter).
If you have managed to successfully solder the two boards together with good continuity on the connections and no short circuits, then congratulations the hardest part of the project is complete!
Step 6: Attach the Volume Wheel
The B103 10K Potentiometer used for the volume wheel is attached to the front side of the motherboard through the labelled pin holes at the top of the board.
Before inserting the potentiometer into the holes, use a piece of the Kapton tape to cover the trace on the motherboard and stop as much of the board as possible coming into contact with the potentiometer.
Then insert the wheel through the pin holes and solder it on from the rear side of the motherboard.
Step 7: Attach the Motherboard Headers
NB: When I built this project I first soldered the headers onto the daughter boards (USB-C, PAM8302 and Powerboost 500C) rather than the motherboard, but this made the construction more fiddly, so I would recommend following these instructions instead.
Headers are required for 4 different parts in total: USB-C Breakout board, PAM8302 Amplifier, Powerboost 500C and the Waveshare Screen. This section will NOT be attaching a header for the Waveshare Screen as that needs to be done after adding the Screen Support in the next step.
The three headers being soldered to the mother board in this step are attached to the bottom of the board, on the same side where they are labelled.
For the USB-C an 8 pin header is required.
For the PAM8302 a 5 pin header is required, plus two additional single pins.
For the Powerboost 500C an 8 pin header is required.
For each of the headers follow these steps:
- Insert the header into the pin holes on the bottom of the motherboard (look for the labels).
- Secure the headers in place with tape/tack so they don't move and stay level (an alternative is to push the other side of the pin header into a breadboard if you have one available)
- Solder all of the pins on the header to the motherboard on the top side of the board.
For the two extra pins for the PAM8302, I found it useful to position them first then place the board onto all of the pins to ensure it lined up correctly, before actually soldering the two additional pins to the motherboard.
Step 8: Attach Wires for Shoulder Buttons
These wires will run from the pin holes labelled "R_SDR+", "R_SDR-", "L_SDR+" and "L_SDR-" on the motherboard, and for now the other side of these wires can remain unattached. The polarity of these wires doesn't matter and the labelling is only there to differentiate them. See the attached image for the finished connections.
- Cut 4 short lengths of wire (2cm to 3cm) and strip a couple of millimetres of insulation of both ends.
- Tin both ends of all 4 wires.
- Insert one end of each wire through the pin holes labelled "R_SDR+", "R_SDR-", "L_SDR+" and "L_SDR-" on the back of the motherboard.
- Solder the wires to the motherboard from the front side.
Step 9: Attaching the Screen
The screen has to stand off the motherboard a particular amount which is where the 3D printed "Screen_Support" comes in. The support is placed on the front of the motherboard, so that the lower section lines up with the SD card slot in the Raspberry Pi Zero 2 W. The screw holes in the support should line up on one side with a through hole in the motherboard (near the SD card port of the Pi) and on the other side in the space cut out at the top of the board for the shoulder button.
Using the M3 x 6mm screws, screw from the back of the back of the motherboard and through the support. Start with the through hole first, and then only slightly tighten the screw which is near the shoulder button cut-out. Looking at the support from the front of the motherboard, ensure that it is level and that the horizontal section runs parallel to the Pi.
Once the screen support is installed and secure this is a good time to insert your pre-flashed RetroPie micro SD card back into the Raspberry Pi Zero 2 W. It can be done after this step, but it becomes much more difficult to maneuverer as the screen will block easy access.
If everything is lined up well it is time to attach the screen:
- Place a 6 pin header through the "TFT_SCREEN" labelled pin holes on the top of the motherboard.
- Position the screen so that the screws from the support sit in the top-right and bottom-left holes of the screen board's screw holes. This should also make the 6 pins from the header go through the top 6 holes of the screens pin holes. Double check that the head is going through the top 6 pins, use the image included as a reference.
- You may need to loosen and tighten the screen support screws slightly so that they bite into the screw holes of the screen and pull everything quite tight. You don't want to over-tighten though as it that will skew the screens alignment.
- Ensure everything is quite snug with minimal gaps between the motherboard and the screen support and minimal gaps between the screen support and the screen board. Make sure everything is as level as possible (the screen should be parallel to the motherboard in all dimensions). If the board is skewed slightly, try slightly loosening the screw by the shoulder button cut-out until everything seems level.
- Solder the header pins to the top of the screen pin holes (see included images)
- Take the two wires coming from the RST and BL pins of the screen which we attached earlier and push them through the corresponding holes on the motherboard just behind the pin header for the screen. The labels for these hole can be found on the bottom of the motherboard.
- From the back of the motherboard, solder all 6 pins from the header to the motherboard, and also solder the two wires for the RST and BL pins.
- On the front of the board try to position the wires neatly so that they won't interfere with the D-pad (see included image)
That is the screen all finished! If you setup the screen's fbcp-ili9341 drivers earlier you can now power on the Pi (using the micro-USB power still at this point) and see if the screen works as intended. If you have not setup the screen drivers yet you can move onto the next step.
Step 10: Preparing and Fitting the Power Switch
The power switch will be attached to the motherboard towards the end of the build, but it needs to have the wires attached and be fitted in the case before the motherboard.
- Cut two medium lengths of wire (7cm or 8cm) and strip a couple of millimetres of insulation of one side of each wire.
- Tin the exposed side of each wire.
- Solder one wire to the middle pin of the SPDT slide switch.
- Solder the other wire to either of the outer pins on the SPDT slide switch.
- Slot the wire switch into position in the front shell of the case paying attention to the orientation. You can have it either way round, but the side of the switch that has the outer wire attached will be the "ON" position (see included picture for my orientation which is "ON" when the switch is pushed towards the centre of the console).
- Use the two M2 x 4mm screws to secure the switch to the front shell.
Step 11: Attach "Low Power" LED
The 5mm Red LED is used to indicate when the battery voltage has dropped down to 3.3V and the console should be charged. It is attached to the bottom side of the motherboard.
- Insert the LED from the bottom of the motherboard through the "LED+" and "LED-" pin holes. Pay close attention to the polarity of the LED, and ensure the negative side goes into the "LED-" pin hole. The negative side should have a flat edge on the LED body, and the positive side should have a longer leg.
- Secure the LED in position with tape/tack.
- Solder the LED from the front side of the motherboard.
Step 12: Cut Down Raspberry Pi Zero 2 W Power Micro-USB Port
This step might be optional, but I found that my Raspberry Pi Zero 2 W had micro-USB ports which extruded further out from the board than the 3D design file used for this project suggested. Whilst this causes no problems for the micro-USB data port, which has cut-out in the shell for it, the unused micro-USB power port pushed against the shell and caused it to bow out.
To resolve this I used flush cutters to remove around 1mm to 2mm or excess metal from the end of the micro-USB port so that it could fit in the shell without catching.
N.B The "Power" micro-USB port is the one closest to the end of the Raspberry Pi Zero 2 W
Step 13: Attach the Speaker Screw Extender
The small 3D printed "Speaker Screw Extender" is just to allow the rear screws to be symmetrical providing the most even pressure when screwing the shell together. Due to the positioning of the speaker having all the screws in the corners wasn't possible, so the "Speaker Screw Extender" allows the motherboard to screw into the front shell internally, whilst a screw can still be fitted in the corner to attach the back shell to the motherboard.
- Take the "Speaker Screw Extender" piece and notice that one side has a through hole and the other has an inset hole.
- Place the "Speaker Screw Extender on the front of the motherboard by the PAM8302 header. It should line up with the two motherboard screw holes and avoid the header of the PAM8302. The through hole should line with centre motherboard screw hole and the inset hole should be pointing towards the motherboard and aligned with the corner motherboard screw hole.
- From the back of the motherboard use the M2.5 x 8mm screw in the top of the two screw holes to secure the "Speaker Screw Extender". Try to get this so when looking through the back of the motherboard corner screw hole, the inset hole of the "Speaker Screw Extender" is lined up.
Step 14: Check Everything Fits
This is a good time to check that everything still fits together. So take the motherboard with all it's attached components and try to insert it into the front shell.
It will have to go in at an angle tilted forwards towards the top of the shell. The board for the screen should slot into the gap underneath the screen support and the potentiometer wheel should slightly protrude through the slot in the top of the shell. It will be a tight fit and the bottom the shell will need to be bent out slightly to allow the mini-HDMI port and micro-USB data port to slide down into their slots.
If everything fits correctly the motherboard should sit on the two screw posts visible through the should button holes, the potentiometer wheel should protrude though it's slots (and still move freely), and the ports on the bottom should line up with their holes.
If there are any fit issues now is the time to identify them and correct them. this might involve some light sanding of some areas or using a modelling knife to remove a little excess plastic (I found that the gap for the screen board underneath the should button mount was often quite tight and needed a small amount of plastic to be cut down).
Some of the screws may need to be loosened and tightened again so they bite into the posts in the front of the shell. This is true of the internal screw for the "Speaker Screw Extender" and the top "Screen Support" screw (in the shoulder button cut-out). N.B To make the console easier to disassemble later, don't tighten the bottom Screen Support screw so it bites into the post in the shell, as this screw will be blocked by the Powerboost 500C once it is soldered in. Instead use an M3 screw that is only just long enough to bite into the screen board, but not long enough that it protrudes any further.
Once you're happy everything fits, loosen any screws that you tightened into the frame, carefully remove the motherboard and components from the shell and it's time to start the final steps of the build!
Step 15: Attach the Daughter Boards
As all the headers are already soldered for the daughter boards should be quite an easy step. All the daughter boards (USB-C Breakout, PAM8302 Amplifier and Powerboost 500C are attached to the bottom of the motherboard with their components facing away from the motherboard (see attached images for orientations).
PAM8302
Simply line this board up with the pre-soldered headers from Step 7, place it as flush as possible and solder it to the 5 header pins on one side and the 2 other head pins on the opposite side. Once finished use flush cutters to cut any extruding pins off.
USB-C Breakout
This board also needs to be lined up with the pre-soldered headers from Step 7, but it will not have any support for the front of the board. You can either use some tack or a small piece of card/plastic to support it whilst you solder, or you can attach this board once everything is fitted in the shell in the next step so that it is supported by its bracket. As with the PAM8302 cut of any extruding pins off when finished.
Powerboost 500C
This board also needs to be lined up with the pre-soldered headers from Step 7, but it will not have any support for one side the board which makes it tricky to keep level. You can either use some tack or a small piece of card/plastic to support it whilst you solder, just make sure it will be easy to remove when you are finished. As with the other daughter boards cut of any extruding pins off when finished. N.B - Once this board is soldered on you will lose access to the screw underneath it for the "Screen Support", so ensure you have got that screw correctly tightened and length appropriate as mentioned in the previous step.
Step 16: Assembling the Front Shell
Before inserting the motherboard and all its components for a final time there are a couple of things to do:
- Insert the D-pad, A, B, X, Y, Start and Select 3D printed buttons into their button wells.
- Peel off the protective cover from the front of the screen.
- Peel off the adhesive cover from the speaker and stick it down into the recess in the front shell ensuring the wires are closer to the inside.
- Align the wires from the power switch so that they will come up between the USB-C and power switch mounting points (check the images for clarification on the position)
Before inserting the motherboard take the two wires from the speaker and thread them through the motherboard and Raspberry Pi screw hole as shown in the included images. N.B Your speaker may come with an attached JST connecter, if so simply cut it off before completing this step.
The motherboard and connected components can then be reinserted and secured into the shell in the same way as Step 14. Once inserted use the two M3 x 4mm screws to secure the USB-C breakout board to the shell.
Finally you can add the shoulder buttons to the build:
- Take the last 2 soft tactile switches and look at the legs. You will notice that two legs are attached on only two sides of the switch body. Cut off both legs from one side of the body, leaving just two legs on the same side (see the images for clarification).
- Push the tactile switches into their mounting points at the top of the front shell, so that the remining legs are facing up. Ensure they are pushed all the way down and the the way back.
- Take the "Shoulder Button Pins" and thread one through each of the "Shoulder Buttons", so that roughly the same amount extrudes on either side.
- Take the assembled "Shoulder Buttons" and place their pins into the holes in the front of the shell. Make sure the lip on the buttons is inside the shell and that the bottom of the "Shoulder Button" is just making contact with the soft tactile switch. (If you are gentle you should be able to test the hinge of these buttons now).
At this stage your build should look like the second image included.
Step 17: Soldering the Final Wires
All that is left to do now is solder the remaining wires to the motherboard and PAM8302 and the build will be complete.
Shoulder Buttons
For each shoulder button, take the wire from the "R_SDR+" / "L_SDR+" and solder it to one of the legs of the soft tactile button. Then take the wire from the "R_SDR-" / "L_SDR-" and solder it to the other leg of the soft tactile button.
Power Switch
If necessary, cut both of the power switch wires down to an appropriate length before removing a couple of millimetres of insulation. Tin the end of the wires and then solder one to the "SWITCH+" pin hole in the motherboard and the other to the "SWITCH-" pin hole. The orientation does not matter. This is a bit of awkward solder as you have to do it from the same side of the board as the wire is inserted, so just try to make it as neat as possible given this restriction.
Speaker
If necessary, cut some length of the speaker wires (in the attached image mine are a bit too long) and then remove a couple of millimetres of insulation for both the black and red cables attached to the speaker and tin the ends of both. The red wire can then be soldered onto the "+" terminal on top of the PAM8302 and the black wire can be soldered on the "-" terminal on top the PAM8302. For clarification, the motherboard underneath these pins is labelled as "AUDIO+" and "AUDIO-". I found it easiest to attach these by re-melting the solder already used to attach the pin and simply pushing the speaker wire into the re-melted solder.
That is all the soldering completed for this project!
Step 18: Plug in the Battery
Before adding the battery, use a good amount of Kapton tape to cover the area it will sit. This is to help hold the speaker cable to the motherboard, reduce the likelihood of any sharp bits of solder making contact with the battery and to protect against short circuits. See the image for the area which should be covered with Kapton tape.
The battery can then be place directly on top of the motherboard so that it's cable points towards the Powerboost 500C. Ensure that your power switch is in the "OFF" position, and the then plug the battery JST plug into the JST connector on the Powerboost 500C.
Step 19: Rear Shell Assembly
The back shell can now be pushed onto the front shell and the two should fit together snuggly.
- Ensure that the pins from the shoulder buttons align with their corresponding holes in the rear shell.
- No wires are getting trapped on compressed as the shells are closed
- The battery is contained within the "frame" of the back shell without having the cable caught.
If everything goes together well then the only bit of construction left to do is to screw it all together. You will need to slightly squeeze the shell halves together to get a good fit, but don't push too hard.
Take the three M2.5 x 20mm screws and insert them through the screw holes on the back of the shell which are NOT in the same corner as the speaker. Don't tighten one up all the way first, but increase the pressure across all of them as you go.
Take the M2.5 x 16mm screw and insert it through the screw hole on the back of the shell on the SAME corner as the speaker. Tighten this one all the way up once the other ones are done.
If everything holds together then you are finished and it's time to move onto the software!
Step 20: Final Software Setup
With the hardware build complete it's a good time to test a few things first before the last bits of software are setup, if you have a mini-HDMI cable it will help a lot before you get the screen working:
- When the power switch is flipped the Raspberry Pi should power on, and the screen should turn white.
- If a mini-HDMI cable is plugged in, the RetroPie should load
If these two things happen then so far so good!
It is useful to have another computer which can connect to your Raspberry Pi via SSH, using a terminal interface (such as PuTTy) and a file transfer/browser software (such as WinSCP for windows). This also means that you need to have your Raspberry Pi connected to the same local network, and with SSH enabled. If you followed the setup steps for RetroPie linked above then this should already be done.
The final software setup can be broken up into 4 pieces; The Screen, The Controls, The Audio and Safe Shutdown.
The Screen
SPI screens are not normally used for gaming projects due to the limited bandwidth available. However, a fantastic set of drivers was written a few years ago which provides great performance for SPI screen using an ili9341 chip (which is what the Waveshare 2.4" screen in this project uses). The driver is fbcp-ili9341 and can be setup quite easily by following the instructions on the GitHub. For a more detailed walkthrough on the process there is a great video by "Bytes N Bits" who steps through the whole process including tuning all the parameters. When following along with either of these guides this project uses the following cmake command and parameters (N.B Only use this command once you reach the cmake step of the setup process):
cmake -DILI9341=ON -DGPIO_TFT_DATA_CONTROL=25 -DGPIO_TFT_RESET_PIN=27 -DGPIO_TFT_BACKLIGHT=18 -DDISPLAY_ROTATE_180_DEGREES=ON -DSPI_BUS_CLOCK_DIVISOR=6 -DLOW_BATTERY_PIN=5 -DSTATISTICS=0 ..
The Controls
To get the controls recognised as a virtual controller in RetroPie I used GPIONext. This is quite a simple utility to use and it creates a virtual controller out of all the buttons on the PocketPi. Launch the shell on your PocketPi (either directly with a keyboard attached or using something like PuTTY over SSH), and execute these commands in order:
cd~
git clone https://github.com/mholgatem/GPIOnext.git
bash GPIOnext/install.sh
sudo python3 /home/pi/GPIOnext/config_manager.py --pins 3,5,7,8,10,11,15,31,36,37,38,40
This should launch a utility which will configure the virtual controller only on the GPIO pins we are using. Follow the on screen instructions to set up "Joypad 1" with "1 D-pad" and "8 Buttons". The final screen of the utility will let you choose which buttons we are assigning, which in our case is "A, B, X, Y, Start, Select, L, R" and then ask you to press each of the buttons on the PocketPi to set it. Once completed you will be prompted to start GIPOnext, DO NOT do it at this stage as we need to limit which GPIO pins it has access to when running first. Instead, once you are back at the prompt in the shell execute the following commands in order:
gpionext set pins 3,5,7,8,10,11,15,31,36,37,38,40
gpionext reload
sudo reboot now
After the reboot has occurred, enter the terminal again and execute the following two commands in order:
gpionext start
sudo reboot now
If you have not registered any controller with RetroPie then you will be able to configure the input for the PocketPi straight away. However, if you have already registered an external controller (keyboard, USB controller etc), then you will need to use that to enter the "Start" menu and select "Configure Input" from the menu to setup the PocketPi buttons.
The Audio
The setup for the audio is thankfully quite simple and just requires a couple of changes to the boot configuration. Using the shell on your PocketPi (either directly with a keyboard attached or using something like PuTTY over SSH) open up the boot config with the following command:
sudo nano /boot/config.txt
Using the arrow keys, navigate down to the line which says:
#dtparam=audio=on
The "#" at the front means this line is commented out and not active, so remove the "#" so that it looks like:
dtparam=audio=on
The font colour should change from blue to white to show it is no longer a comment. Now use the arrow keys to navigate to the bottom of the file and add the following line:
dtoverlay=audremap,enable_jack=on
This will automatically remap the audio to the PWM0 and PWM1 channels and start outputting audio through the PocketPi cicuitary. Use "CTRL + X" to exit and press "y" to save changes. Then use the following command to reboot the PocketPi and audio should work:
sudo reboot now
Safe Shutdown
The final software element to activate is the safe shutdown script which allows you to just flip the power switch to enable an automatic shutdown and prevent corruption of data. Two different scripts are needed for this: a Python script which has the main process for the shutdown (attached to this step), and a shell script which forces emulation station to shutdown properly. As I am unable to share shell script files here, simply copy and paste the following into notepad and save the file with this exact name "es_shutdown.sh":
#!/bin/bash
# Check if EmulationStation is running
ESPID="$(pgrep -f "/opt/retropie/supplementary/.*/emulationstation([^.]|$)")"
# Make $emucall regex-safe to use in the "pgrep -f" below.
emucall="$(sed '4!d; s/\([\\"]\|[[:alnum:]_]\+=[^ ]* \)//g; s/[][(){}^$*.|+? ]/\\&/g' /dev/shm/runcommand.info)"
# If there's an emulator running, we need to kill it and go back to ES
if [[ -n "$emucall" ]]; then
emupid="$(pgrep -f "$emucall" | tr '\n' ' ')"
pkill -P "$(echo $emupid | tr ' ' ',')"
kill "$emupid"
wait "$emupid"
sleep 5 # maybe it can be lesser
fi
# Create the shutdown files to trigger EmulationStation to shutdown and loop until complete
if [ -n "$ESPID" ]; then
touch /tmp/es-shutdown && chown pi:pi /tmp/es-shutdown
kill "$ESPID"
while s=$(ps -p "$ESPID" -o s=) && [ "$s" ] && [ "$s" != 'Z' ]; do
sleep 1
done
fi
sleep 1
Now with these two files ("safe_shutdown.py" and "es_shutdown.sh") saved on your local computer open up your file transfer SSH program (WinSCP etc). Move the two files into the home directory (/home/pi).
Due to issues with file endings in Windows we are going to have to make a quick change to the shell script that was copied and pasted from above. Open a terminal on your PocketPi (either directly with a keyboard attached or using something like PuTTY over SSH). Run the following commands in order to install and run a program which will correct any issues with Windows line endings in Linux:
sudo apt-get install dos2unix
dos2unix es_shutdown.sh
The safe shutdown files are now all ready to be run, and we just need to tell the PocketPi to start the script every time the system boots up. So in the terminal on your PocketPi (either directly with a keyboard attached or using something like PuTTY over SSH) type:
sudo nano /etc/rc.local
This will open the "rc.local" file for editing, which is a script used on boot up to launch any extra scripts and services required. After the line that says "fi" and before the line that says "exit 0" add the following line:
python /home/pi/safe_shutdown.py &
Press "CTRL + X" on the keyboard to exit and enter "y" to save the changes. The PocketPi can then be rebooted with:
sudo reboot now
After the reboot, the PocketPi can now safely be shutdown by just turning the power switch off.
Attachments
Step 21: ENJOY!
At that's everything for this project!
The next step is configuring which emulators you want, and sourcing any ROMs you require, but there is plenty of information out there on how to go about that and the RetroPie website and forums are a GREAT place to start.
Hope you enjoyed this project and please share and comment if you have made a PocketPi or if you are having a problems.
Enjoy!
27 Comments
Question 7 hours ago
Hello, why other Parts on the PCB like Resitors, Capacitors Diods aso are not labeled on the PCB ??? not so cool
Answer 3 hours ago
As they were always planned to be surface mounted devices (SMD), and assembled as part of the construction of the PCB, I didn't include the silkscreen labels on the board for these components to keep the design clear.
There is a full schematic for these components, and bill of materials detailing their specification available on PCBWay if you do wish to source and add these components yourself.
If you need more clear labelling then let me know and I can provide an annotated image of the PCB with the location of all the SMD components.
9 days ago on Step 21
Thanks for this great writeup! Would you be willing to post any details on how to successfully order the PCB and assembly from PCBway? Ordering the PCB is simple but adding components on for assembly always seems to be iffy.
Reply 6 days ago
I would appreciate this also. Trying to work through the order but it’s asking some details on the assembly and I don’t want to get that wrong.
cost comes up to around $55 for uk delivery ( with the slowest postage option ) . does that look right ?
Reply 6 days ago
What I did was after receiving the initial estimate from PCBway which included all the items in the BOM, I responded asking them to only include the SMD components specified in the instructions here (C1-C5, D1-D4, R1-R9). You probably don't want them to include the other components as they won't usually purchase them in a very cost effective way. My price was $65 USD total (quantity included 5 PCBs and assembly for 3 of those), and they gave me free delivery to where I am in the US.
Reply 6 days ago
sounds good, thanks, to be sure, the components listed above would need to be added to the bottom of the PCB?
Reply 5 days ago
I did select the bottom option. I'd think it shouldn't matter since my understanding was that each component location is marked in the gerber file, but you never know.
Reply 6 days ago
I can appreciate the confusion around the PCB assembly, so I'll try to clear it up as much as possible:
As you correctly stated in one of your replies, the components that should be included are C1 - C5, D1 - D4 and R1 - R9 (these are the only parts in the BOM which I didn't mark as "do not place", so I was under the impression these were the only ones PCBway would include by default). All the other components are mentioned in this instructable and can be added to the board as part of the assembly instructions above.
The only side of the board that needs to be assembled is the bottom, as I thought it was more cost/space effective to put all the surface mounted components on the same side.
If you have any more questions just ask and I'll do my best to answer them.
4 weeks ago
would this be ok with a pi zero wh?
Reply 27 days ago
It is compatible with the Pi Zero (it would have to be the version without headers though as it needs to be soldered directly to the motherboard). The ports on the Pi Zero can also protrude a little more which might make it a tighter fit. You will also get considerably reduced performance from what I've seen in benchmarks, and some of the more recent consoles might not be as playable. If you can source a Pi Zero 2 W, then you will have a better experience overall at marginally more cost. Stock for the Pi Zero 2 W is getting much better recently, and keeping track with https://rpilocator.com/ is a good way to see when stock comes in. In the UK, both PiHut and Pimoroni have had numerous stockings of them in the last couple of months.
Reply 6 days ago
thanks !
25 days ago
Awesome writeup and project! Could you post your full schematic diagram? I am interested in how the safe shutdown works and is wired. Thanks!
Reply 24 days ago
Thanks! The full mother board schematic file (for Fusion 360) and a PDF of the schematic is available on PCBWay where you can download the Gerber files or order the motherboard:
https://www.pcbway.com/project/shareproject/Apple_Pocket_Pi_Motherboard_df9e4fe6.html
The design I used is actually an adaptation of something I found on the SudoMod forums. The gist is that you require two pins on the Pi (one for input, one for output). The input pin monitors the state of the switch net and if that goes low then it triggers the safe shutdown script. That script makes the output pin switch from low to high so it is now providing the power to the EN pin of the powerboat rather than the switch. It then initiates shutdown. During the shutdown procedure the output pin is automatically returned to low and the system shuts down. To make sure that these hops between power sources don't cause a premature shutdown some capacitors are used. There are also some dioides used to ensure current is not able to back flow into the pi. On the schematic, the safeshut down circuitry is in the bottom left.
4 weeks ago
Do you have a video of it working?
Best Answer 4 weeks ago
I've now added a 10 minute(ish) sample video of the booting, UI and a range of different games and emulators to the top of the instructable.
If you've got any more questions feel free to ask!
Reply 26 days ago
Cool! Thanks
Answer 4 weeks ago
I have just finished filming some video of it working to show performance on the different emulators. I'll get the video cut up and added to the start of the instructable tonight some time, I'll reply to you again once it's up. Thanks for your interest in the project!
27 days ago
Do you have a rough estimate of how much this project costs?
Best Answer 27 days ago
I can do slightly better than a rough estimate, as I kept a track of my costs during the project.
For EVERYTHING (all the screws/wires, accounting for the cost of printing filament, 128Gb microSD card, all the electronic components, the manufacture of the motherboard, and all delivery/shipping/tax costs): It came to £114.40
If you cut down to a 64Gb microSD card, use a 2000mAh (803860) lipo battery and already have some screws/wires you can repurpose you can get it down to about £95 still including the motherboard manufacture and delivery/shipping/tax costs of everything.
If you already have other components you can use/repurpose or source for less then of course these costs can be reduced even further. The 5 most expensive items in the project from where I sourced them was:
3000mAh LiPo battery (£20.50)
Pi Zero 2 W (£17.00)
Powerboost 500C (£14.70)
128Gb microSD card (£14.99)
Waveshare 2.4" Screen (£12.90)
Every other component cost under £5.
Hope this helps give a bit of an overview on pricing!
4 weeks ago
Nice! Did you also made the gameboy in the pictures? And do you have instructions for that one?