Let's build the power circuit! Here's the circuit diagram again, it's not to scale, and is just a reference for the connections we'll be making.
First, we'll need to make a hole in the back wall for the switch. A good place to put it is behind the upper handle on the left side of SelfieBot. Measure your switch and mark the size and placement of the hole you need.
Carefully drill a hole inside your mark, and use a small hand saw or jeweler's saw to cut material away to make the perfect rectangular hole for your switch. Test fit the switch often, and use a flat file to smooth the edges.
Next, we'll install the power switch. Cut two pieces of red 16 AWG wire about 3.5" each. Strip the ends and solder one wire to each pin on the switch. Slide some heat shrink over each solder joint and heat to tighten. Feed the wires through the hole in the side wall of SelfieBot and push the switch into place. Secure the switch with a generous bead of hot glue around the inside edge.
Add the Battery Connector
Next, we'll add a connector for plugging our battery into the circuit. My battery came with a Tamiya connector, so that's what I'm installing here - if you are using a different kind of connector, refer to the manufacturer's instructions for how to install it properly.
There are three parts to the connector: two metal crimp-on contacts, and a plastic housing. Install one metal contact on a 4" piece of black 16 AWG wire, and the other on one of the red wires coming from the switch.
To install the contacts, strip about 3/8" of the insulation away from the end of the wire. Lay the wire in the channel of the contact so that the insulation starts just before the lowest crimp on the contact.
Using pliers, close the two crimp sections on the contact; the lowest should close onto insulation, and the next one up should close onto bare wire, as shown. (For a more solid connection, solder the wire to the contact after crimping.)
Once your contacts are installed, look at the connector on the battery, and note which sides ground and power are connected to. On my battery, the half-round terminal is the ground side.
Make sure to set up your wires in the same configuration as the battery's wires, so that ground plugs into ground, and power plugs into power.
Insert the contact ends of the wires into the connector housing. They will snap into place. Again, be absolutely sure the wires are in the same configuration as your battery's connector.
Make the Y-Split
Next, we’ll create a split so that the thermal printer gets its power straight from the battery and the Raspberry Pi gets a nicely stepped-down 5v from the UBEC. To do this, add a Y-split to both the remaining red wire coming from the switch, and the black ground wire coming from our newly installed battery connector. One side of the split will run to the thermal printer’s ground and power wires, and the other side of the split will run to the input side of the UBEC.
Note: The UBEC’s input side is the end that the large capacitor is soldered to (it should be the side with thicker wires), and the output side is the end with three SMD resistors and thinner wires.
Make sure your wires are long enough for everything to plug in comfortably: the micro USB plugs into the top of the Pi, the printer power and ground plug into the right side of the printer, and the battery will be located at the bottom of the case.
Finally, add a micro usb connector for powering the Raspberry Pi. I highly recommend using a USB shell for this, instead of cutting up an existing micro usb cable, which is what I did. It works fine, but I had to cut up a couple of cables to find one with decent wires inside.
If using an existing cable, when you strip off the insulation and metal foil inside the micro usb, you will find four wires. We are only using the power and ground wires in the micro usb cable, so cut away the white and green wires.
Slide some heat shrink onto each of the UBEC's output wires, and onto the micro USB cable. Connect the micro USB cable's power and ground wires to the corresponding power and ground output from the UBEC. Cover the soldered connections with the heat shrink.
Your power circuit is complete! We’re ready to plug everything in and close it all up.