NESPi Simple Electronics Guide

This is a electronics assembly guide for those who wish to skip the NFC Reader but still want the front buttons and LED to be functioning. This guide will help you setup the safe shutdown and game reset scripts. You will need the custom usb extender board, front pcb board, and other misc parts. Purchase links are below.

After completing this guide, you can always upgrade your Mini NES to add a NFC Reader.

This guide assumes that you already have an Assembled 3D Printed Mini NES Case. If you have any questions, please post them to the Facebook Mini NES Builders Group.

Tip: You can find combo deals on Amazon for the Raspberry Pi, Heatsink, and Fan.
Note: OshPark is a PCB fabricator. They offer cheap PCBs with free shipping in about 2 weeks. Ordering from them will give you enough PCBs to make 3 Mini NES Cases.

Part List

Before we start you will need to make sure you have:

You can follow this guide without the Mini NES Case. However, you should wait before trimming wire lengths until you have the case in hand to compare to.

Tools List

These tools are useful when following this guide. Approx prices are listed.

If you have never soldered, this is a good beginners project to gain that skill. The above linked solder iron is an inexpensive temperature controlled model. It is easy to use, hard to screw up, and mostly safe to use.

Before you begin, watch this video on youtube to become a soldering pro!. Soldering is EASY. If that video is too long, you can learn from any of these videos in just a few mins.

Remove the SD Card

Damage Warning! If you have an SD Card installed in the Raspberry Pi, remove it now!
The 3D Printed Case has a defect that will snap in half the SD card when the Raspberry Pi is inserted OR removed from the Mini NES Case.

Front Panel Assembly

You will have two almost identical switches for the Front Panel PCB. Do NOT solder the switches onto the PCB yet! Click the switches up and down to figure out which is the Latching Pushbutton Switch and which is the Momentary Pushbutton Switch.

The Latching Pushbutton Switch is the POWER button.
The Momentary Pushbutton Switch is the RESET button.

  1. Snap the button covers on to the Pushbutton Switches.
  2. Install the two switches into the 3D Printed Button Holder before sliding into the Front Panel PCB.
  3. Install the partially assembled Front Panel into the Mini NES Case.

Tip: The fit of the switches and the button covers will be very snug and may take several tries, but they will fit with a bit of force.

  1. Check the push action of each Pushbutton Switch and adjust as needed. Either moving the Pushbutton Switch around or trimming the button cap.
  2. When you are satisfied with the motion of the Pushbutton Switches, use a solder iron to attach the Pushbutton Switches to the Front Panel PCB.

  1. Insert the 220 ohm Resistor into the Front Panel PCB where indicated.
  2. Use a solder iron to attach the 220 ohm Resistor to the Front Panel PCB.

  1. Examine the 3mm Red LED and note that it has two leads, one short and one long. Then examine the Front Panel PCB and note that there is a line next to one of the holes.
  2. Insert the 3mm Red LED into the Front Panel PCB so the short pin is inserted into the hole with the line through it.
  3. With Front Panel inserted in the Mini NES Case, adjust the 3mm Red LED forward so it touching the 3D Printed LED Indicator Lens.
  4. Use a solder iron to attach the 3mm Red LED to the Front Panel PCB.
  5. For added measure, you may wrap the 3mm Red LED in Black Electrical Tape to stop any light from leaking into the rest of the case.

Set the Front Panel aside for now, do NOT glue into the Mini NES Case yet.

USB Extender

  1. Strip one of the ends of the 6 Wire Ribbon Cable.
  2. Use a solder iron and attach 6 Wire Ribbon Cable to the USB Extender PCB, note the colors used and the wire labels on the PCB.
  3. Install the USB Extender PCB into the Raspberry Pi's USB port, then wrap the wire below the Raspberry Pi.
    Ensure that the Ribbon Cable stays flat so it can be installed in the case.

  1. Wrap the Ribbon cable around the edge of the Raspberry Pi next to the SD Card Slot, see photo.
  2. Install the Raspberry Pi into the Mini NES Case.
  3. Install the USB Socket into the USB Socket PCB, and install both into the Mini NES Case.
  4. Measure and trim the excess Ribbon Cable so all wires will reach the pins on the USB Socket PCB. Leave yourself an extra 1/2 inch (12mm) of length to strip.

  1. Remove the USB Socket and Raspberry Pi from the Mini NES Case.
  2. Strip the other end of the 6 Wire Ribbon Cable.
  3. Use a solder iron and attach 6 Wire Ribbon Cable to the USB Socket, using the USB Socket PCB and your color notes to match the wire labels on the PCB.

The USB Extender is now assembled. You may re-install the Raspberry Pi into the Mini NES Case.

Front Panel Wiring

  1. Seperate 4 wires from the Female Jumper Wire bundle.
  2. Insert the Front Panel Assembly into the Mini NES Case.
  3. Measure and trim the excess length from the 4 Female Jumper Wires, Leave yourself an extra 1.5 inches (40mm) length of wire.
  4. Use a solder iron and attach trimmed Female Jumper Wires to the Front Panel PCB.
  5. With the Raspberry Pi installed, you may now super glue the Front Panel Assembly into the Mini NES Case.

  1. Connect the Female Pin Jumper Wires where indicated.
    • Front PCB Ground to the Raspberry Pi Ground pin 9
    • Front PCB SW1 to Raspberry Pi GPIO4 pin 7 (Reset Switch)
    • Front PCB SW2 to the Raspberry Pi GPIO3 pin 5 (Power Switch)
    • Front PCB LED to the Raspberry Pi TXDO pin 8 (Power Indicator LED)

Note: The use of GPIO3 is important for the Power Switch. The software script takes care of shutdown/halt of the Raspberry Pi. GPIO3 has a hardware feature built into Raspberry Pi that wakes up from halt when shorted to Ground.

Cooling Fan

There are vents on the Mini NES Case, however, if you want to have play sessions of longer than a few minutes eventually you will want to add an active cooling fan. Wire the fan into the Raspberry Pi power, it will be always running.

  1. If your fan is not plug and play, splice the fan wires using some of the spare Female Jumper Wires.
  2. The Red Fan wire goes to +5 Volt pin and the Black Fan wire goes to the Ground pin.
    • Fan Red Wire to Raspberry Pi 5V pin 4.
    • Fan Black Wire to Raspberry Pi Ground pin 6.

Raspberry Pi Software

With the Front PCB wired into the Raspberry Pi, you will need to install the safe shutdown and enable the Power LED.

Shutdown Script

  1. Copy and paste the following into new text file and save as shutdown.py
    import RPi.GPIO as GPIO
    import time
    import os
    
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(3,GPIO.IN, pull_up_down=GPIO.PUD_UP)
    while True:
    	if (GPIO.input(3) == True):
    		os.system("sudo shutdown -h now")
    		break
    	time.sleep(0.50)

Note: If you are using a momentary button instead of a latching button for the Power Button, you must update the script to watch for False instead of True.
if (GPIO.input(3) == False)

You may also have to make this change if your switch is mounted backwards.

  1. Connect your Raspberry Pi to your network and power on
  2. Use WinSCP to transfer the files to the Raspberry Pi in folder:
    home/pi/NESPi/shutdown.py
  3. Open Putty to update rc.local.
  4. Once logged in, enter the command
    sudo nano /etc/rc.local
  5. Add the following just before the line "exit 0".
    (sleep 1; python /home/pi/NESPi/shutdown.py)&
  6. Press CTRL+X to exit and Save.

Power Indicator LED

  1. Open raspi-config.
    sudo raspi-config
  2. Advanced Options: Serial Port Enable
  3. Select 'Yes', then 'Finish' to exit.
  4. Reboot your Raspoberry Pi to see your LED is now on

Note: Depending on your retroarch version, you may not see the same menu options. Try "Interfacing Options" -> "Serial"

Reset Script

  1. Copy and paste the following into new text file and save as reset.py
    import RPi.GPIO as GPIO
    import time
    import os
    import socket
    
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(4,GPIO.IN, pull_up_down=GPIO.PUD_UP)
    
    # Sends "RESET" message to port 55355 for RetroArch's network commands
    
    while True:
    	if (GPIO.input(4) == False):
    		print "Reset button pressed.\n"
    		try:
    			s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    			s.sendto("RESET", ("127.0.0.1", 55355))
    		except socket.error:
    			print "Failed to create socket"
    	time.sleep(0.50)

  1. Connect your Raspberry Pi to your network and power on
  2. Use WinSCP to transfer the files to the Raspberry Pi in folder:
    home/pi/NESPi/reset.py
  3. Open Putty to update rc.local and retroarch.cfg.
  4. Once logged in, open rc.local
    • Launch the editor with command
      sudo nano /etc/rc.local
    • Add the following just before the line "exit 0".
      (sleep 1; python /home/pi/NESPi/reset.py)&
    • Press CTRL+X to exit and Save.
  5. Next open retroarch.cfg
    • Launch the editor again with
      sudo nano /opt/retropie/configs/all/retroarch.cfg
    • Scroll down to find the config_save_on_exit option and change to true.
    • Scroll down further and ensure the following are uncommented:
      • network_cmd_enable = true
      • network_cmd_port = 55355
    • Press CTRL+X to exit and Save.

Congrats!
Did you enjoy this guide? Please consider donating by paypal to paypal.me/dustinwestaby