Connecting digitalpin to PC power switch pin...

Now I want to shutdown the computer by using arduino,
but I have problem how to connect the computer power switch to arduino...

The computer power switch pin have +5v and other pin is GND, when you connect each other the PC will shutdown.

How can I connect the computer power switch to adruino digitalpin ? Should I add extra component?

If you only know that, then you need extra components.

BUT, connect one end of your DMM to a random GND point of the PC and the other end to the switch while pressed (doesn't matter witch pin because the switch connects both of course). Do you read 5V or 0V?

I suspect 0V. If so, the 5V line is just pulled up and thus the real switch input. If you power that Arduino from the same PC OR use a separate isolated supply (like a phone charger) of which you connect the GND to the GND of the PC (can be the 0v line of the switch) you can connect the other pin to any IO pin of the Arduino. Although I would only let it FLOAT (pinMode(pin, INPUT)) for not pressed or pull it LOW* for pressed.

If you read 5V, the 0V line is pulled down and thus the real switch input. For that to work you can do the above but you would need a real GND point and you need to drive the pin FLOAT / HIGH.

  • If you only use pinMode(pin, INPUT) and want a driving LOW, all you need to do is call pinMode(pin, OUTPUT)

The component you need is a "logic level" FET.

Look for that on some other enquiries here; you will get suitable types suggested.

Meh, I would say a logic level fet only makes things more complicated. You still need to figure out if you need N or P and I doubt you need it for the current.

If you want simple (as in, no measuring), grab an opto (like the PC817).

Hi,
Do you know that if you have your arduino turning the power supply off, the arduino will need to open circuit the existing ON/OFF button is part of.

Do you realize that when you open the circuit, the arduino will have to keep the circuit open.
If power is disconnected from the Arduino, the computer will turn back on.

Draw a circuit showing how you want to switch the ON/OFF button system please.

Can you please tell us your electronics, programming, Arduino, hardware experience?

Thanks.. Tom... :slight_smile:

@septillion

Would you laugh at me if I say I will use a relay to switch on the PC ?

wait for while, i will test the switch with DMM.

@TomGeorge
maybe a relay is a solution... there are 3 terminals in relay (normally open, com, normally close)

this is my second project in arduino, it will power off the computer when brownouts (at least in 2 minutes), my UPS dont have this function.

i have basic electronics experience, i program a lot...

@mikechale, yes. Because a relay can cause problems of it's own, especial in a PC. If you really don't want to measure anything more, like I said, a opto will do fine. And it's like 100x smaller then a relay. And second, I think that would kind of be a ass move. First ask for help but after we tell you some basic stuff, just ditch everything.

And two footnotes

  • I would not shut down the PC but put it in hibernate. It would really suck if you lost work because of it.
  • Be sure not to activate the "button" to long. >5 seconds will cause a hard shutdown of the PC which your OS does not like.

0V when power switch both pin is connected and that was PULLED UP !

hmmm.. hibernate ? it is good for my gcafepro server, (diskless server) ?

No idea about gcafepro, no idea what it is. I was just thinking normal desktop. :smiley:

And what I suspected. Just pull the line low from an Arduino (don't forget to make a common GND if you use a different supply than the PC itself!) and your done.

okie thanks a lot septillion for your help...

A relay is the ideal way to operate the shutdown or reset buttons as it provides safe isolation from the PC workings . It won’t cause any issues with the PC operating .
Only get involved in this stuff if you know what you are doing .

Place the relay near your motherboard and see if you get weird issues...

Opto also gives full isolation if you desire so (but it's useless if you power the Arduino from that PC really) without the possible EMI.

hi, septillion... we will going to revive this thread, this project is not yet done...

so I will use opto (like the PC817).

but how can i connect this to arduino and pc switch...

Cathode of the opto to GND. Anode via a +-470Ω resistor to an Arduino pin. Emitter and Collector to the header where you connect the power switch. If it doesn't work, switch Emitter and Collector.

Okie for another question:

How to isolate the input using opto to arduino?

The input coming from allan dual timer 5 volts high, 0 volts low.

Do you need isolation? If the Arduino can share its power supply with the "allan" then it does not require isolation.

The advice using the opto as an input to the PC can be copied across to the Arduino inputs too.

Maybe isolation, isolate the ground, the arduino has its own power supply.

Input isolation for my safety, hehe...

I have seen allan dual timer that uses input isolation, that's why i like to copy that work...

This is what i'm doing with my ups, the relay just triggered 2 time, wake & shutdown.
without any timer, you just need put some delay to make interval relay become NC then NO again.

1div_4R_adafruit_mon_loop.ino (10.6 KB)