I saw a post on raspberry official forum. It's about GPIO remote switching PC on/off, but it is not very detailed. I am pretty interested in it and i have this relay. I am wondering if anyone here has done that before. I want to get tutorials or manuals about it. I haven't posted on their forum yet.
First off, two important notes:
Working with mains voltage is dangerous. Some traces on the underside of that PCB will be wired directly to 110/230V mains, and will be exposed. Also, it's potentially a fire hazard. It really needs to go into a proper enclosure and treated with the respect that mains power deserves.
Also, switching the main supply is a really bad way to remotely turn on and off a PC. Most modern computers will remain switched off when power is supplied unless an option is enabled in the BIOS configuration. Switching a PC off by cutting power is a very irresponsible thing to do too, as I'm sure you will know. If you want to remotely boot and shut down a PC, you should use the proper tools. I would recommend wake-on-lan and logging into the machine to activate the shutdown command provided by the PC's operating system.
With this in mind, let's look at the relay board. You can find the schematic for a single channel in at the page you linked in your question:
As you can see, the relay switches terminal two of the three-screw connector (J6) so that it is connected to either terminal one or terminal three. In this respect it works just like a light switch, and you should be able to figure out how to wire it so your device is switched on and off.
Because a relay draws quite a bit of current, we can't activate it directly from a digital output pin without risking damage to the micro-controller. Therefore, the board activates the relay through a transistor. To electrically isolate the micro-controller from the relay assembly, the transistor is activated using an optocoupler. Note that you will only get the benefits of electrical isolation if you connect JD-VCC to a separate supply. If you jumper VCC and JD-VCC together (see the bottom right-hand side of the board), you bypass the isolation.
To use the relay from your micro-controller you connect a digital IO pin to IN4 (or IN1 etc depending on the channel you are using). Note that, in order to activate the relay, you need to pull IN4 to ground. Then we have a potential difference that turns on both the indicator led (IN7) and the optocoupler (U7), which in turn will (through the transistor) activate the relay and connect pin 2 of J6 to pin 1. If you put the digital IO pin high, or in a high-impedance configuration, no current will flow and pin 2 of J6 will remain connected to pin 3.
If you want to turn on A PC remotely, Instead of switching mains power you should instead use the power Switch pins on the motherboard. All you need to do is pulse the switch to turn on the computer.
The advantage of pulsing the pin is that you can also use the same method to turn off the pc as most operating systems support shutdown via the power button. Pulsing the pin shouldn't be difficult with a relay (if you want galvanic isolation) or a FET (more simple).
Alternatively you can bypass the ATX power pin.See this pin out. The pin you want is number 16 (PS_ON). The disadvantage of this method is you need to keep the pin shorted to GND to keep the power supply on. This obviously bypasses the power management logic of the PC.