# Need help in powering RPi, fan and USB hub from Playstation 2 power-switch

#### ThaRaven403

Joined Aug 12, 2015
9
Hi everyone,

Here's the context of my project, which got me interested in electronics. I'm a software programmer, so my skills and knowledge in electronics are basic, and english not being my native language (french is), I'm having a hard time finding the information I'm looking for, probably not using the right terms when searching for information...

So for my project I have an old Playstation 2, which I've stripped its components from, keeping only the fan and the power connector, which uses a rocker switch. What I want to do is to put a Raspberry Pi (model B), a USB hub inside of it, and have everything powered by the same source.

Now I know that I could just remove the power connector and switch, get a power strip in there, and I'd be good to go. But I'd rather try to use the actual power connector with the switch, so that toggling it would power everything inside.

- The power switch is 250VAC 2.5A (the switch is built with the power, so I end up having the black/white wires with the connector at the end).
- The DC converter for my Raspberry Pi is 100-240V input, 5.25VDC 1A output.
- The fan is a Nidec D06R EX 07SS102. From the information I found on the internet, it was used with 2 states in the PS2, low being 4.6V and high being 5.1V. Again from what I found, at 5.1V it was using 137mA.
- The USB hub I haven't chosen one yet, since I'm not sure what options I'll have.

So like I said, the goal would be to turn on the raspberry pi, the fan, and hopefully a USB hub, with what comes from the power switch.

Hopefully I provided enough info for someone to share some tips on how this would be achievable (if it is possible obviously)

Bruno

#### mvmacd

Joined Jan 5, 2015
26
Ok, I will assume you don't know the basics of mains voltage, even though you might just as well.

First, AC mains (120V AC or 240V) is lethal and wires/components should never be touched while a mains circuit powered on, the worst thing that could happen is you'll die, but you might just get a shock.

The AC switch works pretty simple, it just opens the connection between the 2 wires (off) or closes them (on).

The power supply has will have a neutral and hot. If they are identified, try to wire them that way. If not, in most cases it will run either way.

Now with that being said, in order to turn off the fan and Rpi with the PlayStation switch, you only need to wire the switch inline with the power supply. And of course hook up the 5V side. Also you can use rpi and transistor or mosfet to provide pwm speed control, from the output of rpi's IO pins. Let me know if you want more info on that. (Could implement thermometer too for only turning on when it gets hot)

One wire from the mains goes straight to the power supply (preferable neutral but if it's encased it shouldn't be critical). The other goes to 1 leg of the switch, and the other leg of the switch goes to the other power supply pin.

A.c. Neutral -------------------- psu
A.c. Hot -----------|,,,,,|---------- psu
############^switch

There is a crude schematic, hopefully this answers your question! Also I don't believe the pi likes to have its power killed. You might want to run "poweroff" as root to shut down the system prior to switching off the power supply.

Also if you have problems with system stability on the pi, try a higher amperage power supply. 1A should be good, but if you share it with the fan I doubt that will supply enough. Depending on the fan consumption.

Matt

Last edited:

#### ThaRaven403

Joined Aug 12, 2015
9
Wow, thanks a lot for the answer, that explains a lot! FYI I'm far from being an electrician, but I've managed to change some light fixtures aroud the house, thermostats, so I have the "basics" in electricity, if we can call it that way...

A question about the switch (based on some lectures I did on the internet)... Is it true to say that since it allows up to 2.5A at 250V, that on a regular 110-120VAC current it will allow me up to around 5A ?

For the poweroff part, I was so into the electric part of the project that I didn't even talk about it in my post... I actually kept the Reset button from the Playstation 2, that's connected to a 7-pin FFC/FPC cable. My goal will be to get this linked to the GPIO pins of the Pi. That was for me a "phase 2" for the project, but since we're at it, would I be better off trying to splice the cable to get the wires I need, or are there some connectors that I can up easily hooking with GPIO pins ?

Another part I forgot to mention (yeah, I'm on to a pretty big project for someone who's never played with electronics) is I'll be hooking one of those 3.5" TFT screens (sold from Adafruit) to the Pi using the GPIO... Since I plan on putting this screen outside the Playstation case, I'll have a breadboard in between that will stay inside the case.

This brings me to what you said about controlling the fan speed. I hadn't thought about it, since I wanted to do it mostly for the "cool factor" of having the fan spin, but now that you talk about it, it looks like a cool idea to learn a bit more doing this project, so yeah I'd love the info about it! I'll already have the breadboard for the screen mentionned above, so I'm partially ready for other modifications.

Bruno

#### mvmacd

Joined Jan 5, 2015
26
Okay glad that it gives you some insight =)

And no, you cannot assume it will handle 5A just because you only use half the voltage. It is still only rated at 2.5A. However at 120V, 2.5A is about 300W! I doubt you will need that much in a low power device such as the pi (I think it's 5 to 10W, but don't quote me on that). Another thing, if it's rated for VAC and not just V, that means using DC could cause it to fail. Also, I have some switches that I use for LEDs. They are rated for 1.5A, but I didn't realize I had been pushing about 3A through them. They get slightly warm, but still work so far. It's possible it will work fine, but maybe they will fail soon. (It's all heat shrinked and super glued, that's why I haven't replaced them yet). So while you can overdrive a switch, the long term effects aren't certain. It can go either way. At the very least, make sure it doesn't get hot enough to melt or cause a fire.

Honestly, you can hook up the wires however you feel is best. But if you have an old PC, the wires that connect the power switch, LED on front, and cpu fan will be plug and play for the GPIO pins on the pi!

If you don't, you can also buy some on eBay. Look for "dupont jumper".

Ok in regards to the fan speed, I need to know if you have any transistor parts lying around. What about resistors? You will need one capable of handling the load of the fan. You say it runs at ~140mA? That isn't a whole lot, but it rules out the most common cheap transistors. Have you tested the amperage with a meter? If you have a digital meter, put it to "DC mA" and put the red and black leads inline to 5V just like it was a switch. Then you can read the exact current.

If you have no meter, you can just buy a transistor that is sure to handle it. I have to go to work but when I get back I'll look into the PWM part of it. I mostly use Arduino and have done PWM, it shouldn't be too hard on the pi!

Matt

Oh one more thing. If it's only 140mA at 5V, then you probably could run the pi and that together, especially with PWM to reduce speed. But any USB device could use up to 500mA. (They usually don't but can). So for the hub, do you have another power supply?

Last edited:

#### ThaRaven403

Joined Aug 12, 2015
9
OK... I thought only the amps counted, but now you bring the watts in... this is where I'm confused!!

Now with all the talks about amps and watts, I did my homework a little better... First, the power/switch is upgraded! I'll be using the one from my broken Playstation 3 (yeah, I also had a broken PS3). It doesn't fit exactly in the PS2's socket, but I'll trim the plastic... And so this one is 250V~ 6A. I've included a picture of it, just to make sure I explained things correctly about it (this is a critical point in the whole thing so...).

And here's the list of what will end up connected to this...
Raspberry Pi - 700mA
TFT Screen (on the Pi) ~100mA
Fan ~140mA
Wifi USB adapter (mini ones, don't know how much it uses)
Keyboard USB (small one, again don't know how much it uses, and will only be occasionally be connected)
Playstation 2 controller with ps2-USB adapter (don't know either how much it uses)

And, now that I'd have 6A, I guess I could have a USB hub (DC powered) that uses something like 3-4A, right ? If I understand correctly, I'll be wiring the black and white wires of the switch to a 6A converter, and from there I'll be able to send power to the USB Hub, the Pi, and the fan. For that kind of "splitting" (from the converter to the Pi/hub/fan), is there any method that's best ? From what I understand I could send the 5V into a breadboard and wire things from there, would that make sense ?

For the wires, I'll go with dupont jumpers like you mentionned. It was already on my "grocery list" I started making for this project, which also includes the breadboard.

As for your question for transistors and resistors, the answer is definitely a no... This is really the first time I play around with this, so if you're willing to provide the guidance I need, I'll buy what I need based on your suggestions.

Things are really starting to shape up in my head, I truly appreciate the time you take to get me learning! Looking forward to your answer!
Bruno

#### Attachments

• 1.4 MB Views: 5

#### mvmacd

Joined Jan 5, 2015
26
Ok, first of all let me explain a little but about the amps. The 2.5A switch is more than enough, because you are going to be switching the AC mains voltage, not the 5V! Watts are a measure of power, so 300 watts can be 100V * 3A, or it could be 300V * 1A. So you can use the original switch and don't have to worry about overpowering it unless you use 2.5A of current at mains voltage, which is about 300W. (That's 3 100-watt bulbs, in other words a LOT of heat). a toaster (one side) is about 800W in comparison.

However, yes it wont hurt to use a 5V 6A power supply, It's always good to have the power supply max current be ABOVE what you think you will consume.

At 5W of load via the power supply, the amps going through the switch is roughly 42mA (120V * 0.042A = 5.04W). However it's not 100% efficient so it will use slightly more. (Usually 85% or more efficient depending on the rating of the power supply)

As for the wiring,it looks like the switch has a black and white wire. So you have the original AC plug, right? There should be a white and black wire. If not, then label them as such. The white wire from the AC plug goes to the white wire of the power converter. The black wire from AC goes to either end of the switch (let's say black), and the other end (white) goes to the other end (black) of the power converter. This is the only way to properly use the switch rated for AC volts, not DC volts. Drew a quick schematic here:

http://i.imgur.com/dfxWrsW.png

Then, on the output 5V, just wire the devices. Be careful though, a small wire can't always carry a high load of 6Amps. It can get hot or melt. As a rule of thumb shorter the wire, the more amps it can carry. But breadboards cannot usually handle 6A. I don't know exactly how many amps, but I would say it should do 1 or 2. So you can wire it via breadboard, but I recommend connectors that spring shut, or soldering them.

So about the transistor and resistor suggestion, what kind of experience do you have with circuits? Do you have a soldering iron and are you able to make a simple circuit?

Here's another schematic for BJT: http://i.imgur.com/LqQQ8Lx.png
Resistor R1 is to protect the GPIO pin, and also to limit current to the transistor (too much will break it). A value of 1K ohm should be ok.

A MOSFET circuit would be similar.

A BJT will be cheaper but will have a voltage drop (typically 0.7V so instead of 5V it will be 4.3V), and will decrease the maximum speed. (A popular option is the TIP120, around $0.30) A MOSFET will cost more but they have much less voltage drop. Can be slightly harder to set up, but we can get into that once you decide which way you want to go. (Popular option, FQP30N06L, around$1) these are NPN or N-channel which means the ground, not the high voltage, is switched. I don't recommend switching the high side.

Also, you said you were a software programmer. You can look up an example of PWM output, you might have to add a python library, but hopefully that won't be hard. The Pi only has 1 dedicated PWM pin, which I was surprised to find out today. But that is enough. The output of the PWM signal goes to the transistor/MOSFET to switch the load on and off very fast to provide a slower fan speed based upon the actual PWM duty cycle.

Phew! If you don't understand some of that, or if I missed something let me know and I can try to clarify.
Matt

Last edited:

#### ThaRaven403

Joined Aug 12, 2015
9
Just wanted to say first and foremost thanks! I'm off to sleep in a couple of minutes, so I'll read back and reply tomorrow or during the week-end, because I want to make sure I got all my head to read (and hopefully understand) this! Since there is a lot of stuff I knew nothing about a couple of days ago, I want to be sure I understand before going forward and/or asking questions...

I just wanted to point something out though, my AC plug is actually built with the switch. I've added another picture that shows the other side of the component. So the wire from the wall plugs in there, with the on/off switch, and this goes to the black and white wires you saw in that other picture.

Oh, and for the soldering experience, I've never done this before, so this could be my first time (unless there is a way to breadboard that stuff).

Thanks again, talk to you in the next couple of days!
Bruno

#### Attachments

• 1.5 MB Views: 6

#### mvmacd

Joined Jan 5, 2015
26
You're totally welcome.. Oh rats! I didn't realize the switch is all wired in with the plug! That makes it simpler, those 2 wires (which now make sense that they are black and white, as the connector is polarized) go straight to your power adapter's 120V input!

Ok, so do you own a soldering iron? I do not know if you can use a breadboard with 120V. Can someone else verify this? I did a quick search about this, and I found a post saying they shouldn't be used for more than 500mA here: http://electronics.stackexchange.com/questions/117994/how-much-current-can-solderless-breadboards-handle

So yeah, maybe they shouldn't even be used for 1-2A like I said earlier! Anyway, a soldering iron would be a good investment if you want to do electronics. My favorite is an old (quality) wooden-handle 60W soldering iron.

But if you just want to connect things without solder,a quick and easy way is with spring connectors.

Take a look at that. They do cost money (about a quarter a piece in a lot of 10), but they're convenient and reusable. They are rated for mains voltage, and up to 10A!

You can find them in a bigger lots for cheaper. Hopefully you also have spare wire. A good place to get some is an old PSU from and old computer. I also use the ribbon type IDE connectors for general purpose circuit wire. (They're grey and connect to hard drives, and such)

To strip the wire, you can use a sharp knife as long as you're careful. Just cut all the way around, rotating the wire rather than the knife. And pull off!

But know that with cheap prices comes the other cost of waiting for China airmail! I'm waiting for parts myself, it's a struggle. I advise you to buy in advance all you will need so you don't have to wait as long once they all arrive.

#### ThaRaven403

Joined Aug 12, 2015
9
OK... now that I've read back everything... For the power converter, I found this while browsing on amazon... http://www.amazon.ca/iDsonix-trade-30Watts-External-Devices-Black/dp/B00FDLI9U4/ref=sr_1_2
Could this be what I wire with my switch? This way I would already have the USB output for the Pi, I could get a USB to barrel for a USB hub (that would use max 2.1A), and one of the other ports to power the fan. It also seems to me as this would reduce the risks of wires getting hot or melting...

As for soldering, I don't have a soldering iron (should've told you when I answered about my [no] skills for soldering. But from what I understand (please correct me if I'm wrong), since the fan only uses around 140mA, I could have the resistor and MOSFET wired up on a breadboard, right? To me, this would be a nice start and would help keep the project's expenses (I'm already busting the budget I had planned with the attached screen).

Speaking of parts, I'll be adding a 1K ohm resistor and a FQP30N06L MOSFET to my grocery list. For the price difference, I'd rather have the stability the MOSFET seems to provide.

As for the spring connectors, could this also be an option? https://www.adafruit.com/products/1496
I'm already ordering something from there, so it would be less of a hassle than waiting for Chia airmail! I totally feel your pain on this, I've waited more than a couple of weeks for stuff ordered from there!!

And yeah, no worries about the python part! I had already looked up how it works for the reset switch, so this should be the part I'm most comfortable with!

Slowly but surely, I think we're getting there! If I haven't said something that can't be done in this post, I think I could be ordering pretty soon!!

There might just be my "issue" with the Playstation Reset button cable... I've included a picture, have you already worked with those pesky cables? Am I crazy thinking I could just strip the wires, test to find the ones for the button to work, and use them ? Since the board is already in place, I'd love to just connect to it to have the reset button power the pi off.

And another big thanks to you! Have I said you will obviously get to see a video and pictures of everything once it's working ?

thanks!!
Bruno

#### Attachments

• 1.4 MB Views: 3

#### mvmacd

Joined Jan 5, 2015
26
That USB power supply would work fine! The only thing is, you'll have to connect the 2 prongs to the wires. Not sure how to do it, but I would probably solder them myself. Guess you'll have to figure that one out!

Yeah, those splice connectors should work, although I'm not certain how the connect. But remind me, what do you need to connect with wires again? I believe the Pi takes a micro USB for power in.

Yeah, the breadboard should be able to handle the fan okay. Also I found this:
It says to use a 10K ohm resistor. (I would buy at least 5, they are pennies each. Shipping will be the biggest cost) a 1K would also work but it would let more current flow from 5V to GND, so it might as well be 10K. A MOSFET needs a pull-down resistor to make sure stray voltage doesn't accidentally switch it on and keep it stable in the "off" position.

A 1/4W resistor will be fine, but you can get 1/2W too. (More wattage, the more heat it can dissipate)

Also you'll notice the diode across the motor. A fan is a motor, motors generate backwards voltage when the electromagnetic fields collapse (turn off the motor) so a diode is placed backwards, to let the reverse voltage spike short out instead of damaging the MOSFET. I would buy a diode or even 5. The 1N7001 diode will be a good choice. They're also pennies each, so get extra in case break or fry any. (Polarity is very important! Double check it before you power the circuit)

Speaking of the fan, just make sure it only has 2 wires coming out! If it's a 3 wire motor, then it's much harder to control.

Ah yeah, that connector is a type of ribbon cable. Extremely hard to work with! I think there are some LEDs on there, and 2 stitches. That's why it has 7x leads. I'm not sure the best way to attach a connector to the ribbon cable. If it was me I'd try to disassemble it and look for solder points I could run wires too. I really don't know what the best thing for you to do it with what you have!

But yeah, with a meter on continuity "beep" mode, or ohm mode, you would look for 2 leads that are open (0L on a digital meter) when button isn't pressed, and low resistance (0 to 5 ohms usually, or continuity beep) when depressed.

Glad that your project is coming along! As for the thermister I was talking about earlier, I would say just get it up and running and then after maybe you could implement that. It's harder that I thought after finding out there's no analog to digital converter, so you need an external IC to read the exact temperature reading.

Last edited:

#### ThaRaven403

Joined Aug 12, 2015
9
You know, you're right about the connectors, there's nothing I need to connect with this anymore! For the power supply, I'll try to see if I have someone around me who's done some soldering before that would be able to get it soldered with the switch...

I've been browsing on the www.digikey.ca website trying to find the components. The MOSFET I found, no problem with this one. But the diode (1N7001) wasn't found on the site, and for the resistors there are 187 results matching 1/2W and 10k ohm. Would you mind if I asked you a little more guidance on this ? If there's anything that you'd recommend, or that I should avoid, I'd love to know.

And I can confirm the fan is only 2 wires, so it should be "easy" For the switch it will probably be a step 2 of the project. For the moment I can still run the sudo shutdown command, and I'm keeping the buttons anyway so that when I do it, it will look the same as the PS2 button. I also thought, if it's too hard, that I could buy a switch and hide it behind the button, it would give me the same result.

For the temperature monitoring, to be honest, I had totally forgot about that part... So that might go to step 3, first I'll need the fan running anyways.

Bruno

#### mvmacd

Joined Jan 5, 2015
26

http://www.digikey.ca/product-detail/en/1N4007-TP/1N4007-TPMSCT-ND/773694
I guess they cost 0.15CAD each (vs about a dollar for 100 on eBay if memory serves), so If you only get 1 that should be ok. Maybe get 2 just in case you short one out. Haha!

This resistor will work: http://www.digikey.ca/product-detail/en/CFM14JT10K0/S10KQCT-ND/2617659

Any 10k resistor should work. There are 1/8W, 1/4, 1/2, 1W, and the list goes on! But your use won't burn excessive power so that is the only big factor whem deciding on the size. If you find any cheaper resistor on there, go ahead and get it (just make sure it looks similar to the one I posted with leads on each end). Theoretically you only need 1 but you could get a few extra.

I can't believe how expensive it is! I usually buy parts 100x at a time on eBay. Most capacitors are 1 cent each this way. Oh well!

Okay, hope you can get it soldered up. Just don't go overboard with excessive solder, in case you decide to use the power supply for something else in the future.

#### ThaRaven403

Joined Aug 12, 2015
9
Hi,

It's been a little while... I actually ran into budget priorities, and didn't buy the necessary parts until now... So I'm just waiting on them to arrive to get this project finally up and running !

So I read back the thread a couple of times to get back into it, and after also browsing a bit on the web, I'd have a question for you (if you don't mind), that got me a bit confused.

Looking at the diagram you put the link to (the one with the Arduino and solenoid), I see the "0-60V+" wire for what will power the fan, and the "0-60V-". The second one is the one I'm confused about. Say I use a USB cable that I stripped, would I be using the GND wire where the "0-60V-" is on the diagram ? It seems to make sense in my head, since it ends up in the GND on the Arduino (RPi in my case), but since I would prefer not to screw up anything, I'd love if you could confirm...

Thanks again, you'll soon be able to see this up and running!
Bruno

#### mvmacd

Joined Jan 5, 2015
26
Hi,

It's been a little while... I actually ran into budget priorities, and didn't buy the necessary parts until now... So I'm just waiting on them to arrive to get this project finally up and running !

So I read back the thread a couple of times to get back into it, and after also browsing a bit on the web, I'd have a question for you (if you don't mind), that got me a bit confused.

Looking at the diagram you put the link to (the one with the Arduino and solenoid), I see the "0-60V+" wire for what will power the fan, and the "0-60V-". The second one is the one I'm confused about. Say I use a USB cable that I stripped, would I be using the GND wire where the "0-60V-" is on the diagram ? It seems to make sense in my head, since it ends up in the GND on the Arduino (RPi in my case), but since I would prefer not to screw up anything, I'd love if you could confirm...

Thanks again, you'll soon be able to see this up and running!
Bruno
Yes, that's correct. If the USB cable will provide the power to the fan, the ground wire from the USB goes to 0-60V- (it really should be labeled ground).

Hope it works out for you!

#### ThaRaven403

Joined Aug 12, 2015
9
Well, things are looking good, I have my circuit ready as per the diagram you gave me the link to!

Only thing that blocks me at the moment is the 5v input. I thought that I could just splice the USB wire open (coming in from an Anker PowerPort) and get the red and black wires on the breadboard's power rails, but that doesn't seem to work.

So I'll just have to find a usb power adapter for the breadboard and I should be up and running! Unless you tell me that should've been working, if so I'll try to check my wiring...

I'll keep you posted and try to send a picture when I am at home!

#### mvmacd

Joined Jan 5, 2015
26
That's strange, it should be working.

What color are the wires? Do you have a wire stripper or did you just use a knife?