Can a microcontroller control its own power?  Well nearly!

An ATX power supply, either new or from an old PC, is a great way to power Arduino and other microcontroller projects.  That is covered in several 'ibles such as this one.  However, because of some of the special features of an ATX, we can use it as a "smart" supply that's even better.

This is a very simple 'ilbe that will allow you to make a lead that will allow you to control an ATX power supply from your microcontroller.  That way you can use your old ATX as a silent, low-waste power supply for low current microcontroller applications and switch it under firmware control to a high-current monster supplying tens of amps at 5V and/or 12V.

A video showing the idea in action is embedded in the final step.

Total cost of the control lead is a few pounds and you will not damage your power supply in any way so it can be used for other applications later if you wish.

Step 1: Things You Need:

This project requires:

An ATX motherboard extension cable (£2 inc delivery from e-bay)
3 jumper leads
A 1K resistor (value not critical)
Some heat-shrink tube


Soldering iron & solder
Lighter to shrink the heat-shrink

For use:

An ATX power supply
A 5V microcontroller such as an Arduino
High power transistors etc to control stuff.

Step 2: Background

An ATX supply is a wonderful thing!

Looking at the sticker of this supply that I picked up new for £15, we see that it can supply a well-regulated:

20A at 3.3V
30A at 5V
30A at 12V

Plus a stand-by current of:

2A at 5V

Now 2A at 5V is ample to run nearly any 5V microcontroller, while 30A at 5V or 12V is enough to power pretty much anthing short of an aluminium plant.

All we need to do is tap into the 5V standby power to run our controller board and then switch on the high-current supply when we need it.

Step 3: Making Up the Connector

The ATX power connector is well known and the pinout is available online, such as here:

What we need is the stand-by 5V power (purple), the control wire (green) and any of the black ground wires.

Start with the female end of the connector (well, I take that to be the female end - the one in the first picture) and clip off everything we don't need close to the connector.  Then clip off purple, green and black close to the other end.  Slip some hear-shrink over these three and strip these wires and the jumper wires we are connecting to.

We are going to add a 1K resistor to the control wire just because we can and it avoids any risk of excess current flowing when we pull it low with the microcontroller.  So, solder the resistor to the green jumper lead and then to the green wire from the ATX extender.  Solder the purple and black wires to the corresponding jumpers (in my case red and black).  Finally, heat your heat-shrink.

Step 4: Controlling and Using Your Arduino ATX

Using Arduino as an example, all you need to do to use and control your ATX supply is:

Power your Arduino with the purple (red in the picture) ATX wire to +5V (don't use Vin) and the black ATX wire to Gnd.

Connect the green ATX wire to any control pin.  I have used A0 (D14) because you can see it in the picture but a general digital IO pin works just as well.

Plug in your ATX and your Arduino will be powered bu the main power and probably the fan will stay off.

When you need full power just issue the command:

const int ctrlPin=14; // use whichever pin you wish.  I have used A0 which maps to D14.
pinMode(ctrlPin, OUTPUT);
digitalWrite(ctrlPin, LOW);

To turn the main power back off, use:
digitalWrite(ctrlPin, HIGH);

Equally, to turn off, you could simply set it to:
pinMode(ctrlPin, INPUT);

to set the pin to high resistance again.*

Now all you need to do is connect your high current load to any of the MOLEX type connectors from the ATX supply and control them with transistors, MOSFETs etc as you normally would.  When you reach the point in your sketch when you want full power, just issue the above command and fire up the 30A supply!

Note - you should be careful powering your Arduino direct to the +5V.  If you also connect the USB cable then you could get a current flowing to you USB port of your PC so take care to connect only one power source at a time.

The ATX specification suggests that you can either hold the line at +5V or disconnect (set high resistance) to turn off the main power: http://www.formfactors.org/developer%5Cspecs%5Catx2_2.pdf

Step 5: ATX Control in Action

This short video is of a dawn-light alarm clock project (that I will write up sometime but there's a lot to it).

Edit - full dawn/sunrise alarm clock instructable now here: https://www.instructables.com/id/LED-Dawn-Sunrise-Alarm-Clock-Nightlight-Secur/

You can see that the Arduino controling the time display is powered the whole time but initially the fan on the ATX is not running.  That's because we are only using the standby power.

When I fire up the main LED lamp (about 9W of LEDs at the moment but will be more later), the Arduino powers them by switching on the main ATX power and you see the fan start to run.  When the main light goes off again, so does the main power.

For an alarm clock project it's very useful because you don't want the noise of the fan running all night.  There are many similar situations where the muscle of the main ATX power is only needed occasionally.

Hope you find it useful.

<p>does the green wire have any voltage on it that would damage the Arduino </p><p>thanks </p><p>Dwight</p>
<p>Some of them can source nearly 100ma from the PS_ON when connected to GND. That shouldn't hurt your Arduino during testing***, but it will not turn the PSU on, since the Arduino isn't rated to sink more than 40ma. See my comment above for details and how to fix the issue.</p><p>*** Trying to sink more current than your Arduino can sink will most definitely burn up the pin (or your board) if the current is high enough and you let it run long enough. The only reason this probably won't kill your board, is because it is only a bit over the max amperage spec, and because you would recognize a problem and unplug it before damage occured.</p>
The green wire should be a high-impedance &quot;sensing&quot; connection, like an Arduino &quot;input&quot; pin so should not be any threat to your Ardu'.<br><br>I put a 1K on that line out of an abundance of caution because that limits the current if there were any issues. However, it should be completely unnecessary.<br><br>My only caveat here is that there are many makes and builds of ATX power supplies and although they should all conform to similar standards I have not made any attempt to test them widely. It is therefore just possible that _your_ ATX supply is different to those I have tried. I think the chances are very small, but if in doubt, put a meter on the pin, then ground it and measure the current flowing.<br><br>Ugi
<p>I was testing this on some old PSUs from my &quot;closet of obsolete computers&quot;. </p><p>For some of them, I needed to use an NPN transistor to get the PSU to turn on, because they sent &gt;90ma from the PS_ON to GND. (More than an Arduino can sink)</p><p>To solve the issue, I hooked the transistor up like below, and changed the code to be high for ON and low for OFF. Most any NPN you've got in your bin should work.</p><p>NPN Transistor connections:</p><p>Base &lt;--&gt; 2.2K resistor &lt;--&gt; ctrlPin</p><p>Collector &lt;--&gt; PS_ON</p><p>Emitter &lt;--&gt; GND</p><p>(These were PSUs that may or may not have been flaky enough to be the reason they ended up in my &quot;closet of obsolete computers&quot;. Not PSUs that I would trust to run a computer well. PS_ON being low-impedance could easily because these PSUs were &quot;bad&quot;. They all worked well enough for the non-computer destinations I planned for them. :) )</p>
<p>This is a great job! <br>Do you think its possible to connect an arduino and a raspberry pi to the 5v standby?</p>
<p>Yes, you can, BUT..... I've heard a few saying if you try to connect some of the arduinos (R2 and back) +5V line, it can do damage to the circuit that switches from the USB +5V to the regulator +5V.. (haven't actually seen this myself.. Duiemilinova worked fine..) as long as you're not pulling too hard on the 2A standby (with an arduino? not likely.)</p>
That depends a lot on what you are using your RPi for and the spec's of your ATX.<br><br>The power supply I used was rated for 2A at 5v standby. Now we know a normal Arduino will run off a computer USB port which provides 500mA max, so providing you are not adding too many high-power devices to that, we'll say that needs 0.5A.<br><br>For normal use they recommend 5v 1.2A for the RPi: https://www.raspberrypi.org/help/faqs/#powerReqs<br><br>However, if you are using lots of USB ports on the RPi then you might need more.<br><br>For normal use, however, we need 0.5A for the Arduino and 1.2A for the RPi, which makes 1.7A, fitting nicely inside the 2A standby available. So looks like for a &quot;normal&quot; setup, it should work fine.<br><br>Ugi
<p>Thanks a lot for your valuable input.</p>
<p>Great job!</p><p>One question: can i boost the voltage from the atx +5vsb to 9v using a LM2577 DC-DC Step up Power Module Adjustable Voltage Power Converter Module so i can power the arduino using the power jack (7-12v) so i can also use the usb connection without having to hack the usb cable (power) nor use the 5v pin ?</p>
Hi - Thanks for your interest.<br><br>So long as you don't draw more current than your individual 5vsb allows then yes, certainly you can do that. You are burning power stepping up and then regulating back down, but it is formally a more &quot;correct&quot; way to power the Arduino. You could probably boost to 7-8v rather than 9v, however.<br><br>You should expect that to boost 5v to 9v, assuming a less than perfect efficiency, you would approx double the current drawn. Therefore, if your +5vsb is rated 2A on your ATX (that's what mine says) then you should not expect to draw more than 1A at 9V. I doubt you need to use more than that, bearing in mind that anything you need to power beyond the Arduino itself can always come direct from the +5Vsb.<br><br>Good luck with your project!<br><br>Ugi<br>
<p>Thank you for your reply..</p><p>is mi intention is to only power the arduino from the 5vsb, so i can still control the psu, and remain with a active normal usb connection, all other devices will be powered from the psu 12v rails.</p>
<p>Great work. I am looking to do this with a Raspberry Pi. Any reason that it wouldn't work? The Pi uses 3.3v GPIO, but that shouldn't have a problem pulling down the 5v signal from the PSU provided that the unregulated ground ground on the Pi is connected to the GPIO ground. Let me know if you've tried it. Thanks,</p>
Not tried it but no reason I can think of why it shouldn't work. Just two points that occur to me (they are probably obvious):<br><br>You will need to switch by going from High Impedance (input) state to pulling low - I don't expect you can turn the power off reliably by pulling &quot;high&quot; to 3v3.<br><br>It makes me more inclined to put the resistor in the circuit to avoid any stray currents. I can't immediately see how the situation would be different but I would hate to see you &quot;bake&quot; your Pi!<br><br>Would be interested to know how it goes.<br><br>Ugi
<p>Great work. I am looking to do this with a Raspberry Pi. Any reason that it wouldn't work? The Pi uses 3.3v GPIO, but that shouldn't have a problem pulling down the 5v signal from the PSU provided that the unregulated ground ground on the Pi is connected to the GPIO ground. Let me know if you've tried it. Thanks,</p>
<p>Just a note to let you know I have added this instructable to the collection: <br>Encyclopedia of ATX to Bench Power Supply Conversion <br>&gt;&gt; <a href="https://www.instructables.com/id/Encyclopedia-of-ATX-to-Bench-Power-Supply-Conversi/" rel="nofollow">https://www.instructables.com/id/Encyclopedia-of-ATX-to-Bench-Power-Supply-Conversi/</a><br>Take a look at about 70 different approaches to this project.</p>
Great - sounds like a useful collection!<br><br>Ugi
<p>I accidentally fried my arduino when I hooked it to the power supply. Oops...</p>
<p>Guys i got a question, with this i can control when the psu is on or not, but can i use the psu to control a blinking led, the same way i do it with the arduino for example?</p>
<p>Is there any issue with using an ethernet shield and power flowing back through? Or does that only affect the USB connector? Also would rigging a DC jack from the ATX 5v power supply be a safer way?</p>
I have not used the ethernet shield but this should be exactly the same as using the shield with USB power. If the shield is safe to use from usb then it should be fine with direct 5v power. <br><br>Connecting to the Jack connector or Vin only works if you have around 7 to 12v . There is no 12v standby on an ATX as far as I'm aware. <br><br>Ugi
How would you set this up in paralell with the power button inside a pc? <br> <br>(like to turn it on/off via IR or someting) <br> <br>This has some awsome potential :)
<p>u realize that the motherboard is the one handling The power supply right?<br>well u can manipulate the power button logic of the PC though<br>like a short pulse for turn on, long pulse for forced-off</p>
I am afraid I have never tried to control an ATX while still inside the PC! I think you might struggle becuase the motherboard has control of the main power at that point. <br> <br>My guess is that the power button just tells the motherboard that something is happening and the logic on the MB (powered by the standby power) pulls the control pin low when it's needed. I expect it's possible but I don't immediately see a way without causing trouble. Would love konw if you find one thou'.
<p>This is a nice conversion however AFAIR the Arduino should really be supplied with 7-9v because at less than 7v it's onboard regulator will have trouble supplying 5v to the board. This shouldn't put the microcontroller out of spec, but it may cause issues with anything you are driving/powering from the Arduino. IE anything TTL.</p>
<p>Hi Tachyon</p><p>Thanks for your interest in the project.</p><p>What you say is true, but only if you apply power to the barrel jack or Vin pin. If you apply directly to +5v then you bypass the regulator and there is no voltage drop. This is how the Arduino is powered from USB - direct to +5v rather than through the regulator. Of course you need nice smooth power but if an ATX is smooth enough for a PC it'll do for a little Arduino.</p><p>This powering direct to +5v is why you need to be careful not to apply other power at the same time - you could get power flowing to your USB port etc if they are connected simultaneously.</p>
<p>You're right of course. I missed that you were powering direct to the +5v rather than to Vin. My bad.</p><p>That said, you might want to add a brief explanation of the three power input options on the Arduino and why it's important to use the direct to 5v rail in this case. It could be confusing to new Arduino users which is which and why it matters. Especially since the 5v is not just an input.</p><p>Not that your instructable is lacking or should require that info as it's complete for the topic it addresses. But it would be a nice addition.</p>
Thanks Ugi,<br> <br> I managed to get the power on working fine by connecting an Arduino pin to the power button and pulsing it high then low. I may alter it by putting in a voltage divider since when I used a multimeter and read across the motherboard power button pins it is normally 2.5V, and Arduino is giving it 5V.<br> <br> <br> (<a href="http://s22.postimg.org/jvomu1iwx/20130513_221350.jpg" rel="nofollow">http://s22.postimg.org/jvomu1iwx/20130513_221350.jpg</a>)<br> <br> I think a MOSFET is the way to go. I am building this for an arcade: using a coin slot to add credits which adds time, and this then the Arduino enables the joysticks and buttons. For the inputs I have hacked gamepads and connected buttons to them - each button connects to a common +ve (not a common ground) and the MCU. I'll just a P-type MOSFET to switch the common +ve on/off as per credit timer. I think this is better than controlling the USB connection itself. Each button draws less than a mA (i think they drew about 50uA each) so I think a MOSFET or Bi-pol should work should work.<br> <br> Thanks for your help!
Sounds like a cool project - thanks for the update. I'd be interested to see it when it's done. <br> <br>Ugi
Hi Wildman! <br> <br>There should be no problem leaving out the 1K. I had it there because it worked fine for me and, particularly in development, it never hurts to be sure that you won't get a massive current flowing where you don't expect it. If it works without the 1K then leave it out, although you could always put a meter between the control line and ground and see how much current flows, just to be sure. Chances are it will be tiny but if I did that I don't now remember what reading I got. <br> <br>You should be able to tell whether the main power is on from the grey &quot;power good&quot; line. The ATX pulls that high once the main power has stabilised at its assigned voltages. Might be easier and/or more reliable than the power LED. <br> <br>As for controlling the power to devices, that may depend upon what you want to do. The voltage drop across a typical NPN transistor is probably a little too high for the 4.5V minimum standard on a USB port and most will only handle 100-200mA. If you are just taking about a keyboard/mouse then that's not likely to be an issue. Low current USB devices use up to 100mA, which should be fine. <br> <br>For higher current and/or more sensitive devices you might have problems, however, in which case you could always use a low on-resistance MOSFET (the only one I have used recently being IRF540N, which is probably way over-spec'ed for what you need but still only around 75p each). <br> <br>Good luck! <br> <br>Ugi <br> <br>
I found a simpler solution to turn on the pc, maby tro this in te huture.
Awesome Instructable, Ugi!<br> <br> Just a quick question, as I'm not super familiar with ATX power supplies. I see from the ATX Wikipedia page (<a href="http://en.wikipedia.org/wiki/ATX" rel="nofollow">here</a>) that the ATX's 20 pin mobo connector (that you modify in this guide) has +12V &amp; -12V wires, and these don't explicitly appear to be stand-by. Will they go live when the Arduino activates the power supply, along with the other Molex connections?<br> <br> I ask because, for applications that only require a single 12V feed, it seems like it might be &quot;cleaner&quot; to draw power from this main 20 pin connector, rather than plugging in a separate 4 pin Molex if it isn't necessary.<br> <br> Thanks!
Thank! - and yes, yare are absolutely right. <br> <br>All of the yellow wires go to +12V when you fire up the main power. The blue -12V is the same. Be aware, however, that the -12V is a very low current supply. I think you can take 0.5A from the -12V whereas the +12V is good for 10s of amps. <br> <br>Ugi
This is fabulous. Thank you. I solemnly swear that I will only use my power for &quot;GOOD&quot;.
Thank you for your comment. I'm sure we are safe in your hands. <br> <br>Ugi
This is a great idea. <br>I would like to know is there more code for this than shown in step 4? <br>Thanks <br>W
The great thing about this is that once it's connected up you only need a few lines of code. <br> <br>To turn on the main power, just set your control pin to OUTPUT and write it LOW. <br> <br>To turn it off, either set to INPUT, or write it HIGH. <br> <br>It really is as if an ATX supply was made to be controlled by an Arduino! <br> <br>If it takes more than about 4 lines of code then you are over-complicating things! <br> <br>Ugi <br> <br>PS apologies for the deleted comment - I got the HIGH and LOW the wrong way around first time and I couldn't edit it.
This is for turning the power supply on, correct? <br> <br>void setup(){ <br> const int ctrlPin=0; // use whichever pin you wish. I have used A0 which maps to D14. <br>digitalWrite(ctrlPin, LOW); <br> <br>} <br>void loop (){ <br> <br> <br>Would this have the power supply behave the way you have in the video, on with a load attached and off with no load? <br> <br>No need for the apologies friend! <br> <br>W
That's the idea, only you want ctrlPin to be a global variable, so you need to define it outside of setup().&nbsp; You should also probably explicitly set ctrlPin to OUTPUT, but otherwise yes, that would turn on the main power during the setup() routine. If you wanted to turn it off again during the loop() routine then you would write it HIGH or set the pin to INPUT, so if you had:<br> <div style="margin-left: 40.0px;"> &nbsp;</div> <br> <div style="margin-left: 40.0px;"> const int ctrlPin=0; // sets which pin to use.</div> <div style="margin-left: 40.0px;"> void setup(){<br> &nbsp; pinMode(ctrlPin, OUTPUT);<br> }<br> void loop (){<br> &nbsp; digitalWrite(ctrlPin, LOW);<br> &nbsp; delay(10000);<br> &nbsp; digitalWrite(ctrlPin, HIGH);<br> &nbsp; delay(20000);<br> }</div> <div> <br> you would set ctrlPin to OUTPUT in setup(), then you would turn on the main power for 10 seconds, followed by turning it off again for 20 seconds.&nbsp; You would get a similar effect to that shown in the video - the fan and main power would come on for a while, then go off again but the Arduino would keep running.<br> <br> Ugi</div>
Ah i c i will remember that &quot; global &quot; now. <br> <br>This sketch we define the on and off times. <br>It appears in the video it is &quot; on demand &quot; or are the on and off defined there also? <br> <br>Thanks for your help. As you can probably see i am starting out with coding, so i appreciate you coaching me. <br> <br>W
You could control it however you choose. In the video, I am reading a rotary encoder which controls the light that you see in the frame. When the sketch turns on the light, it also turns on the main power because it would take too much current for the standby power. If you look at the &quot;button&quot; example sketch for Arduino: http://arduino.cc/en/Tutorial/Button<br> <br> You will see that it turns an LED on and off with a switch. You could use the same sketch to turn the power supply on and off at the press of a button. You would include the above definition of ctrlPin and set it to OUTPUT, then in the loop, you would use:<br> <br> <div style="margin-left: 40.0px;"> if (buttonState == HIGH) { // turn Main Power on:<br> &nbsp; digitalWrite(ctrlPin, LOW);<br> }<br> else { // turn Main Power off:<br> &nbsp; digitalWrite(ctrlPin, HIGH);<br> }</div> <div> <br> Ugi</div>
OK <br> <br>Thanks much.
This will defo come in handy for when I make my own work bench power supply
Great! It seems such an obvious thing to integrate an ATX with a microcontroller - they are so well suited for each other - but I haven't seen it done before. Hope it proves useful. Would love to see the result.
I've got a fair few power supplies laying around gathering dust, I knew you could use them for bench supplies... but this will defo come in handy...
Thank you for this information! Not so much for the Arduino control, but for the info about the ATX. <br> <br>I started right away changing one of my previous projects. Now I can use that powersupply on standby; 5v 1.2A. I can start it up to full power with an on/off switch, or it turns itself on if I connect anything that needs power from 12v, 5v or 3.3v. :-)
Thanks! <br> <br>That's the great thing about instructables - whatever you do others will find great applications for it that you either never thought of or never had time to pursue. Glad to be of help.

About This Instructable




Bio: Call me Ugi. Special offer! Make something based on one of my instructables and post a picture for a free 3-month pro membership (while stocks ... More »
More by Ugifer:Handheld Pong & Invaders on the cheap (Arduino compatible) Kid's Science Project - Reusable Hand Warmers Make a High-Altitude Balloon Tracker (Arduino) 
Add instructable to: