PiSwitch

67,724

329

18

Posted in TechnologyRaspberry-pi

Introduction: PiSwitch

About: Hey my name is Chris, welcome to my instructors page. I'm happily married with a wonderful son, he makes the best workshop assistant ever. Plus I find a 7 year old has much more creative ideas than me. I wo...

Welcome to the PiSwitch

Hello to the wonderful world of instructables. Sometimes this website feels like a second home to me I spend so much time drooling over the projects I wish I had the time and money to make. Alas, It's finally time for me to drop on you amazing people, my second instructable I call it The Pi-Switch. It's a conglomeration of the work of many people but this particular build is, certainly and uniquely my own. I do however want to give credit where credit is due. First off much thanks to Drew Wallace with the Switch Berry I couldn't make his software work but he helped get me started. Thanks to Adafruit they built the PiGrrl2 a while back and if the internals to my pi case seem familiar that's because the charging circuit and audio amplifier are the same circuits used in the PiGrrl 2. Third Thanks to the wonderful developers over at the pi foundation, RetroPie, and last but not least Kodi. My scripts are built around the incredible work you've done developing software to run on the raspberry pi. Finally, thanks to Nintendo for making me want to reverse engineer, poorly might I ad, their Switch Console.

Epilog Challenge 9

Runner Up in the
Epilog Challenge 9

Step 1: Procuring Provisions

You will need:

Tools:

Soldering iron + solder + soldering flux

Hot Glue Gun

A 3D Printer or $20-$40 and 3dhubs.com

A decent micro screwdriver kit

A Dremel Tool with a fine bit or a drill with a 3/16th bit

Patience

Parts:

Pi Foundation 7" Raspberry Pi screen

Kingwin 80 Piece Assorted Notebook Replacement Screw Kit or (various screws of fortunate sizes lying about)

26 awg wire

1/8 inch stereo jack with switch

Mini Metal Speaker

tiny power switch

6600 mah battery of plentiful life

Joy-Con Controllers (reccomend the addition of a charger)

Raspberry Pi 3 (Bluetooth and WiFi built in)

PAM8302 2.5W Audio Amp

PowerBoost 1000C

3d Printed Case (Files Are Attached to this step the instructable assumes you've printed the part.)

Optional:

PiCamera V2

Step 2: Soldering Headphone Jack to the Pi

I have pictures from the various steps above.

Start with the Pi and solder some 26 awg wire to it:

I used red for the left audio to pp26 near the audio jack (thank you pi foundation for labeling the solder pads)

solder black for ground to pp24

right audio is a yellow wire and you solder it to the upper left pin on the audio jack.

UPDATE: 3-26:

Some more testing showed to me that PP24 directly to the metal pad is ground PP25 is right audio and PP26 is left audio. Picture of updated solder pad usage attached.

I recommend leaving the wires long 3-4" you can trim them down or tuck them in later. I leave them long because my projects often get pulled apart and rebuilt/re-purposed. I really like this particular 1/8 in jack. I chose it because the clear top means you can see and understand exactly how it works.

Soldering The Audio Jack (The pinout is in pics above):

Take the red wire from the pi and solder it to pin 2 on the 1/8 in jack.

Take the yellow wire from the pi and solder it to pin 5 on the 1/8 in jack.

take the black wire and twist another 3-4" length of black wire to it then solder to pin 1 on the 1/8 in jack.

solder a 3-4" red wire to pin 3 on the 1/8 in jack.

You should now have an audio jack connected to the pi, if you were to play sound with headphones plugged in you would have music playing clearly on this jack. I reccomend hot gluing the wires on the bottom of the pi and the bottom of the jack in order to secure the thin wires and also to protect them from damage and shorts.

Step 3: Soldering the Power Board & Switch

The PowerBoost 1000C for all your lithium charging needs.

Unfortunately this little deal though fantastic does not output enough power to run the Pi-Switch. It does however do a great job charging the battery which has plenty of amperage to power the pi, screen, and audio simultaneously for about 2-3 hours. I left the power on the pi open so that running out of battery just means you need to plug directly to the pi. I'm working on a better solution still. I may build a switching circuit. I will update this if I find a better way to power this device but 2-3 hours isn't bad.

Power Leads:

Lets start by looking at Picture 1 above you'll notice 3 black circles and 3 red circles.

You Guessed IT !! solder 3 10" black wires and 3 10" red wires to the corrosponding spots marked on the PowerBoost.

The Switch (The Power Switch (Not Nintendo)):

Cut a single right or left leg off your switch and solder on a 2" wire to the remaining center and alternate legs of your amputee power switch.

solder one of the wires from you switch to en on the powerboost and the remaining wire to gnd on your powerboost board.

Hot Glue is cheap, quick, and easy. I reccomend now putting some hot glue over each of the wires connected to the PowerBoost Board

Step 4: Speaker and Audio Board and HeadPhone Jack (A.K.A. Tying It All Together)

This is the step in which we combine our various assets

Solder the Speaker:

Look at the picture above and solder one wire to each of the pads on the speaker as shown above. I'm too cheap for heat shrink so if you're like me HOT GLUE!

Solder the audio board:

grab your PAM8302 look at the writing. On the side where the board says 4-8 ohms solder your speaker wires to the two center pads as pictured above.

Solder the power to the audio:

Take one of you red power leads and one of your grounds from you PowerBoost board and solder the red wire to vin on the PAM8302 and the black wire to gnd on your PAM8302.

Solder headphone to the PAM8302:

Take the red wire from your headphone jack and solder it to A+ on your PAM8302

Take the black wire from your headphone jack and solder it to A- on your PAM8302

Solder the Pi:

There's a picture of the pi above. Take one black wire from your power boost solder it to the black dot on the picture of the pi.

Take one red wire from your power boost solder it to the red dot on the picture of the pi.

Testing:

carefully be sure the remaining black wire from the power boost and red wire from the powerboost aren't touching anything. then attach the battery and flip the switch. if everything is hooked up correctly an led should light on the pi, on the charge board and you may hear a light buzz from the speaker if it's noisy enough to bother you you likely have an issue with you solder joints.

Step 5: Assembly

We should now have everything attached with exception of the LCD and the optional pi camera. in the first few pictures you'll see how to screw in the pi itself. it's quite simple, so pull out your kit of 80 various laptop screws find some screws just a mm or two longer than the thickness of the pi and thread them into the soft printed plastic. PLA is recommended. there should be two lovely pegs to set the pi on, and on the opposite corners there's holes to thread. the same goes for the power board. there's pictures above that shows the assembly of the power boards.

now push the switch through the tiny hole above the power board. grab the switch from the outside with with some tweezers or finger nails. While pulling gently on the switch to keep it from falling back into the case put some hot glue on the backside of the switch as pictured above. once the glue has cooled double check that the switch is in a good position for use. If it's not good peal off the glue and try again.

Drill a 3/16th inch hole between the pi and the powerboost you can also dremel a hole. This should be on the side of the case where the pi's usb ports are located. Slide the headphone jack into the hole and hot glue it in place.

Finally, glue the speaker battery and audio boards in place as pictured above. I put the speaker facing the plastic under the battery which i tucked directly behind the powerboost board. Then I glued the battery up against the sides of the 3d printed case. Ffinally I glued the speaker amplifier the top of the battery.

So if you've done everything right this far you should have the pi, powerboost, the PAM8302, the speaker, the power switch, and the battery all installed and secured in the back of the pi case. There should also be one 10" black wire and one 10" red wire left.

Step 6: Adding the Screen and Finshing Assembly

Pat yourself on the back you're almost done with a rather complex assembly. now take some 6mm long screws and thread the side bars. They should thread into the screw holes on the screen as shown in the pics above. If the screen doesn't line up and fit you probably have it upside down. Look at the pictures and you may notice I have prototyping wires attached to my screen. I actually put pin headers on my powerboost instead of soldering direct. if you followed through step by step without looking ahead then you're soldering the wires on. if not it's your choice. I prefer pin headers for quick easy modification because my creations are always in a state of flux and improvement.

Use the remaining Wires:

Solder the remaining red wire from the powerboost to the vin pin on the screen

Solder the remaining black wire from the powerboost to the gnd pin on the screen

Attaching The Camera (Optional):

plug the camera cable into the camera board

plug the cable in the pi as shown above

flip the camera over the ethernet jack.

bend the cable flat and glue in place.

Attaching the screen ribbon:

Plug the Ribbon cable in to the pi as shown

if you look at picture 5 it shows how I flip the back panel down into place after attaching the ribbon

Finally screw the four screws from the back panel into the brackets on the back of the screen and you're fully assembled.

Step 7: Building the Pi Software Image

Step 1)

plug a keyboard into your pi, and make sure the pi is plugged into a charger.

Go to this website and follow the install: (only setup your keyboard as a temporary controller)

https://github.com/RetroPie/RetroPie-Setup/wiki/Fi...

Step 2)

You may have an annoying buzz sound (It's ok ignore for now, we'll fix it soon)
go through the ReroPie Menu as follows to setup wifi:

retropie / settings > raspi-config > interfacing options > SSH > Yes > Ok > Finish > Retropie Setup > Configuration Tools > wifi > (configure your wifi) > exit >

step 3)

Install Pixel:

raspbiantools > Install Pixel Desktop Environment > yes > (wait a while) > ok (to flash player) > (wait a while longer) > ok > cancel > back >

step 4)

Install Kodi:

Manage Packages > Manage Optional Packages > Kodi > Install from binary > (wait a while) > back > back > back>


step 5)

register and connect your JoyCons:

Configuration /Tools > bluetooth > Register and Connect (while pressing the tiny button between L and R on the right joy-con) > choose Joy-Con (R) > NoInputNoOutput > (wait) > ok > ok


step 6)

repeat step 5 with Joy-Con (L)

step 8)

cancel > back > exit > (start button) > quit > quit emulation station> yes

step 9)

type the following:
sudo apt-get update && sudo apt-get upgrade && sudo rpi-update
sudo reboot

step 10)

type the following:
wget  https://raw.githubusercontent.com/cfoote7/PiSwitc...
sudo chmod 777 setup.sh && sudo chmod a+x setup.sh 
./setup.sh

Update:

I've added a controller connection menu, where the screen will tell you if both joy-cons are connected. also added a one player two player mode selection menu. on first competed boot you will now connect your controllers with the + and - buttons, click next, click retropie, and choose 1 player mode.

Old:

when the device gets to the touchscreen boot menu tap + and - to activate the two controllers and tap retropie.

Choose retropie hit start > configure controllers > configure your joycons

Tada this is your first boot to the completed device. Now you just need to set it up with your own media and roms.

Check back for updates with automatic controller connecting and parsec for computer to pi game streaming.

Notes:

pywx.py is my touchscreen boot selection menu, it's not actually a boot selection being that all these options exist under one raspbian jessie build. I plan on adding a simpler way of pairing the controllers at boot to this menu. check back for updates, and please let me know if you build this especially if you make any improvements I'd love any co-op on this that's offered. Please check back on my repository I'll be updating it https://github.com/cfoote7/PiSwitch

Thanks for looking if you have any questions about my custom built hardware or software feel free to ask I like to answer questions and find ways to make my instructables clearer :)

Share

    Recommendations

    • Space Challenge

      Space Challenge
    • Science of Cooking

      Science of Cooking
    • Spotless Contest

      Spotless Contest
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    12 Questions

    Hey buddy,
    Great instructable.. I am making this now. Got my Screen in the mail and 3d printed the body!! fits a treat also.

    I was wondering i have a Raspberry 3 B+ will your image work on that?? or do i need to use the Model B...

    Also is there a link to a complete IMAGE of your system so that all is set up and i can just image my SD??

    Thanks again and i look forward to sharing my pics of my Piswitch.

    Hey

    thanks for the response on Github, Unfortunately the 4.3 version doesn't work on the B+

    i will have to wait for you to finish the 4.4 version.

    Cheers

    1 more answer

    Just to add to this.. I even plugged it in to my raspberry pi 3 model b.. With the same result... I thought it migjt be a model issur but clearly it isint..

    Any thoughts buddy.. I would love to get this off the ground before i order the other parts.

    Hi Chris. I really love what you've done here and I got the case printed and bought everything I needed. I get to step 10 and after running the setup.sh, I get a black screen with a blinking cursor. If I reboot it, it has the same thing.

    Any ideas as to how to help things along will be appreciated.

    Hey buddy...
    I got the same thing.. Were you ever able to solve the issue? Or did you get an answer from this guy.

    1 more answer

    1

    This is more than likely either the config .txt or a corrupted card. config.txt could cause it if you're using different hardware than me. If you dont mind going to my github

    https://github.com/cfoote7/PiSwitch/issues

    and reposting this question under issues. Include any possible hardare differences you have. and I'll work with you to resolve the issues you're having. I've followed my instructions step for step several times with different pi setups and haven't ran into that particular issue but I'm certain we can work it out together. :)

    If I dont wanna do the full same build and just use the joycons on my own build could I just do steps 9,10 on a normal retropi build?

    0

    No unfortunately that wouldn't work, I have a lot programs interacting together with specific hardware requirements. If you're linux competent You could download my joymap folder from my github repository though. Then modify autostart.sh to include the line "sudo hciconfig hci0 piscan" that line makes the bluetooth continuously scan and work with multiple Bluetooth devices simultaneously. This is the line I use to start retropie in single player mode with both controllers,
    sudo /home/pi/joymap/loadmap /home/pi/joymap/joycon & emulationstation" loadmap is the program that loads a controller map for the joycons, I modified the program joymap to work with the joycons which it doesn't natively. the file joycon is a text file with the controller map configuration. The problem with this method is my program notifies you when both controllers are connected and doesn't map the controllers until your bluetooth is connected. so you have to have delay on running loadmap until both controllers are bluetooth connected. I hope that was helpful for you.

    Hi! Thanks for the walkthrough - love it! It took me a few attempts to realize that I should base the initial Retropie on Jessie rather than Stretch, but with that figured out, it was mostly smooth sailing.

    Two questions for you; the first is rather the more important one. I have the two joy-cons connected, and the buttons seem to work perfectly, but nothing recognizes the analog sticks. Is there something more required to get them working?

    Secondly, is it possible to change the images on the TouchBoot screen? I tried simply replacing the .jpgs with other images of the same filename, but that doesn't seem to update it. I'm not sure where the touchboot script is reading the images from if not the NewTouchBoot directory - is this something compiled?

    Thanks again - this is an awesome project!

    do we 3d print the stl files in mm or cm

    I have a Raspberry Pi 2 B. Can I use this? It doesn't have Bluetooth available. I have a wifi dongle that works.

    Can I use a different controller for this? Something like a NES USB controller?

    0

    You can certainly do that but if you do I'd just install the standard RetroPie without my customized software. my software is specifically a touch boot menu to choose your boot os using the touch screen and to use the switch controllers immediately at boot. I do have an older revision of my software without the switch controller configuration built into it. if you'd like my older version of the software for the touch boot menu only email me and I'll help you out.

    I am making the piswitch using small screen

    https://www.amazon.co.uk/gp/product/B013JECYF2/ref...

    All went well after the rapi update. However after step 10 I do not see the touch option and it goes right to retropie after piswitch start up pic. Do you think as I am using a small screen? I can see my joy cons both connected as keyboard I have no problem mapping using retropie menu. Once in the game the mapping gone a bit funny.

    Hope you dont mind asking as I am new to linux code. Thanks. Pat

    Hi Chris, thanks a lot. Seems adding the line /opt/retropie/configs/all/autostart.sh to the config.txt does fix the disconnecting problem. The only problem I can think of is the connecting process. Keep on pressing plus and minus does not seem to always work. For me the best way to get them connect is to press reset and plus button during the pairing. It does work at the end but I do hope connecting them to pi is more reliable is the future.

    Keep up the good work. I could show my build later once I finalise the parts.

    6 more answers

    0

    Hi There PatPat I absolutely know the fix for the joycons disconnecting and its running this command

    "sudo hciconfig hci0 piscan"

    if you're starting with a retropie image then make sure that this line is in /opt/retropie/configs/all/autostart.sh

    otherwise put it in /etc/rc.local

    Hi Chris I installed the driver via Raspian and it just works right away.. Joy con connection is not quite stable and keeps on disconnecting.

    0

    When they worked for you did you get the touch boot menu?

    Hi Chris, Thank again. I got the touchscreen working now. The only problem I have is the connection stability of the Joycon. My joy con sometimes doesn't let me connect during the touch screen screen. Also, once connected and the retropie doesn't recognise as a keyboard (gamepad instead) so I cannot do one player. They work once for me as a keyboard mode and I managed to play as 1 player then it stops working again after reboot.

    This is a great project. Hope it works well at the end.

    0

    For the screen that I have you don't need special drivers. if you need them for the 5 inch or if you have to setup extra stuff for the 5 inch that's not a screen I have in my own kit so I can't support it. I have no way to test it. if someone sends me a screen I'll happily test it, get it working and support it.

    Hi Chris, thank you for your quick reply. I am installing everything from beginning up to connecting my joy con. How do I install the 5inch touch screen driver?

    18 Comments

    First off, This is brilliant! Thank you for posting!
    I've gathered all the components, and I'm ready to start assembling this. I'm very excited to try it, but right off the bat, I'm confused. My Pi 3 B already has a headphone jack. Your enclosure file includes a round hole perfectly located for that Jack. So, why do you want to add one? Am I missing something?

    Again, thanks for posting!

    2 replies

    Great question. I left the built in headphone jack intact for testing but the purpose of using a different headphone jack was that the headphone jack I used has a built in bypass. so if there's no headphones plugged in then it will forward the sound signal to the amplifier board and your speaker. that way you have sound with or without headphones plugged in. if you plug in the headphones to my headphone jack it will cut out the speaker and output the sound through your headphones.

    Ah, that makes perfect sense. I've almost got this thing finished, I'm just waiting on the Joy-Cons to show up. I've been gaming with a keyboard and its Ok, but I can tell the joy-cons will help. I've also been trying to set up Kodi, and I think I almost understand whats going on, but i've never used it before, so learning tons. So thanks for responding and keep up the great work.

    Neither, it's a completely seperate home-made retro gaming machine that happens to use joy-con controllers. It's also a ciomputer and a media center.

    oh i got you i might try to make one as soon as i have the materials

    I've ordered the 3D printed model for this one and most of the parts. Looking forward to building it. Thanks for the tutorial :)

    1 reply

    Excellent, letm e know how it turns out. If you have any troubles I'd be happy to offer support.

    Cool. I may have to make one myself. Luckily a friend I know in Canada has a 3D printer.

    Amazing work! This is the first project that I have seen that has made me want to go get my own 3D printer... LOL..

    Thanks I hope it works out good, if you have any troubles with the build I'm happy to answer any questions you have

    Awesome project. I couldn't find the info on the screen that you used. It's not in your parts list.

    1 reply

    Thanks, I plan on continuing to update this and make a public repo for the software so keep your eyes open for updates :)