[Guide] Use a Raspberry Pi to Power on a PC Remotely

So that day I was thinking, how to power on my PC or reset my PC remotely, I did think about WOL, but if the PC experienced a GSOD or a BSOD, I will have no way to recover it remotely. So I came up with a idea of using relay modules for power on PC. Here’s how you do it.

I’m not responsible for any shorts that destroyed your Pi or PC, you did it yourself!

Tools & Materials

  1. Raspberry Pi any model
  2. Arduino Relay Board
  3. Arduino Power Regulator Board
  4. 5V 2.1A Power Supply
  5. Jumper Wires
  6. Electrical Tape
  7. Some Magnet Tape (Or other things you can think of to place the Raspberry Pi in place)
  8. A SD Card for Raspberry Pi Operating System
  9. A Raspberry Pi OS, I prefer DietPi
  10. Some brain power (actually no you don’t need that, you have that already)

Getting Things Ready

  • Download the OS and put it in a SD Card, boot it for the first time, for details, click here
  • Assign a LAN Static IP for your Pi for port forwarding, forward port 22 for SSH control, in case you are brute forced, try port 222 or 2222 so that the machine isn’t smart enough for attacking your Pi
  • In case of a dynamic IP address, use no-ip or other relevant service to give yourself a easy to remember URL
  • Open up your PC chassis and have a look at your power pins, so that you’ll know it later

Wiring the Pi

I prefer this way (Pi 2B), open up a new tab for the image

Software

Wiring Pi is a good GPIO controlling software since it provides basic function and easy to use commands

To install Wiring Pi, read here

Using command

gpio readall

to know which pin are you connected to, the outcome should be somewhat similar to this

 +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |   2 |   8 |   SDA.1 |   IN | 1 |  3 || 4  |   |      | 5v      |     |     |
 |   3 |   9 |   SCL.1 |   IN | 1 |  5 || 6  |   |      | 0v      |     |     |
 |   4 |   7 | GPIO. 7 |   IN | 1 |  7 || 8  | 1 | ALT0 | TxD     | 15  | 14  |
 |     |     |      0v |      |   |  9 || 10 | 1 | ALT0 | RxD     | 16  | 15  |
 |  17 |   0 | GPIO. 0 |   IN | 0 | 11 || 12 | 0 | IN   | GPIO. 1 | 1   | 18  |
 |  27 |   2 | GPIO. 2 |   IN | 0 | 13 || 14 |   |      | 0v      |     |     |
 |  22 |   3 | GPIO. 3 |   IN | 0 | 15 || 16 | 0 | IN   | GPIO. 4 | 4   | 23  |
 |     |     |    3.3v |      |   | 17 || 18 | 0 | IN   | GPIO. 5 | 5   | 24  |
 |  10 |  12 |    MOSI |   IN | 0 | 19 || 20 |   |      | 0v      |     |     |
 |   9 |  13 |    MISO |   IN | 0 | 21 || 22 | 0 | IN   | GPIO. 6 | 6   | 25  |
 |  11 |  14 |    SCLK |   IN | 0 | 23 || 24 | 1 | IN   | CE0     | 10  | 8   |
 |     |     |      0v |      |   | 25 || 26 | 1 | IN   | CE1     | 11  | 7   |
 |   0 |  30 |   SDA.0 |   IN | 1 | 27 || 28 | 1 | IN   | SCL.0   | 31  | 1   |
 |   5 |  21 | GPIO.21 |   IN | 1 | 29 || 30 |   |      | 0v      |     |     |
 |   6 |  22 | GPIO.22 |   IN | 0 | 31 || 32 | 0 | IN   | GPIO.26 | 26  | 12  |
 |  13 |  23 | GPIO.23 |   IN | 0 | 33 || 34 |   |      | 0v      |     |     |
 |  19 |  24 | GPIO.24 |   IN | 0 | 35 || 36 | 0 | IN   | GPIO.27 | 27  | 16  |
 |  26 |  25 | GPIO.25 |   IN | 0 | 37 || 38 | 0 | IN   | GPIO.28 | 28  | 20  |
 |     |     |      0v |      |   | 39 || 40 | 0 | IN   | GPIO.29 | 29  | 21  |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+

Since we’ve connected GPIO Pin 6, 13, 19 and 26, we can use the highlighted Pin number to write the shell script.

For Power On/Off (Press the power button)

#!/bin/sh

gpio mode 22 out #set pin 22 as output mode
gpio write 22 1 #set pin 22 as high
sleep 1 #pause for one second
gpio write 22 0 #set pin 22 as low

For resetting

#!/bin/sh

gpio mode 23 out #set pin 23 as output mode
gpio write 23 1 #set pin 23 as high
sleep 1 #pause for one second
gpio write 23 0 #set pin 23 as low

Now it’s done, you can power off your PC when you are on the go and call it to wake up anytime you want. No need to deal with WOL setup! And no need to worry a BSOD.

 

if you find the guide helpful, consider donating me @ cydia2020@live.cn

Your donation will make a difference




No Comments


You can leave the first : )



Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.