Monday, August 17, 2015

An aside: USB Power Switch

 If your like me, you don't want to have to unplug the power from the wall or you Raspberry Pi every time your done, or dig to plug it back in. The solution? A simple switch, built right into you USB cable.
***WARNING: This is a power switch, it will not shut down your Raspberry Pi. That you will have to do manually on the Raspberry Pi. Failure to do so will damage your Raspberry Pi***
Now that that is out of the way...
Let us do this!
<!--more-->
 The first thing you will need is a USB cable. Don't bother with the super expensive 90' ones. This simple one from Walmart for powering a phone will do fine.

This one comes with a micro and mini usb end. We only need the one, and are going to  cut the cable anyway. So, take the one you want, set the rest aside.

After you have cut the one you want, DO NOT cut the rest of the wire yet. Just strip the ends of the red and black wires inside. This one doesn't have them, but a data cable would also have a green and white, plus some shielding. We don't have use for any of these, cut them back. After you have stripped the wires, twist them so there are no loose wire, the tin them(presolder). This will get us ready for the next step.

Next, slide some heat shrink tubing big enough for the cable all the way to the plug. Then put some smaller over the red wire. This is positive and will be soldered to the switch. Choose a switch. Any two pin will do. Connect the red wire to one of the pins. It doesn't matter which, but will decide how the switch lays along your cord. Solder it in place, slide the smaller tub up, and shrink it around the exposed end of the wire and as much of the pin as you can. Leave the ground(black) alone for now.

Now that you know better how long the male end is with the switch,  cut the male end to the length you desire. I made mine short as it will be going from a battery to the Pi, right next to each other.

 Then repeat what you did for the first pin on this side. Don't forget a piece of large tubing for the whole wire, and a smaller one for the positive where it connects to the switch.(As you can see above, I did) After you have both positives connected and your ground wires pretinned, add a heat shrink tube to one side, and splice them together. I like to add a little more solder, but some just use the pretin to connect them. Shrink the tube around the join. I then take a small piece of electrical tape and fold it over the to terminals(pins) on the back of the switch. This will protect them from shorting on anything that may be around. Make sure it sticks out, onto the cable on either side. Then take both of your two larger tubes, slide them as far under the switch as you can, with the ends of the tape inside. Then shrink them all down, giving you a nice clean back cover, with no exposed wires.

I have seen people use some epoxies to cover the back, giving it a hard stiff, protective cover. Your final product should take into account the environment it will be subjected to. Mine will be inside another case, with only the switch visible, so a soft back will do fine.

Thanks for reading, I hope you found this useful in some way.

Until next time, keep building.

No comments:

Post a Comment