Wake on LAN with Raspberry
Background of a problem
My flat is rather small so I use two laptops – my Thinkpad (with Arch Linux on board) and companies MacBook Pro. As you can imagine – they aren’t good gaming equipment. Fortunately, I also have a PC with Windows and rather good graphic card (Geforce 1070 8GB is enough for my current requirements) but it’s located in my “garage”, near to my Raspberry (which is hosting this website).
Steam has a functionality to stream video games over local area network called “Steam Remote Play” so I can play on Mac or Thinkpad by streaming games from my PC. Imagine those “ultra” graphics on regular laptop … 🙂 You can find more about this solution in Steam’s documentation.
My PC has a motherboard without Wake on LAN (WoL) functionality so I have to make a small trip to my “garage” to switch on the PC and then go back to the living room each time I want to play something. It is annoying because it takes me around 2 or 3 minutes. I’ve decided that I need to find a solution. And I found. My Raspberry Pi!
Solution of the problem
What we need
- Raspberry Pi (any version with GPIO)
- Three contact wires (female<->female)
- One channel relay
- One pair of wires from UTP cable
- 2 electrical connectors
Pictorial diagrams
This diagram gives you general overview how it is supposed to work. We will have an option to start the PC using Raspberry and also maintain functionality of the power button on the PC case.

Please note: you don’t have to use the same pins on GPIO, as long as the ones you choose are still 5V pin, ground pin and gpio pin. It is just the example. You can check your pin layout using pinout command:
Connections
Here are connections from Raspberry side:

Connecting one channel relay:


Connecting relay to power button:

Python script
It is rather simple but by default Raspbian uses python 2, so firstly we need to install python 3.
sudo apt install python3
Ok, now we are ready to create our script:
nano startPC.py
and copy/paste this code. You can change the pin number in line 5 and 6, according to your selection:
import RPi.GPIO as GPIO import time GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) GPIO.setup(25, GPIO.OUT) GPIO.output(25, True) time.sleep(0.5) GPIO.cleanup() quit()
Hit ctrl+o to save and then ctrl+x to exit. Running this script requires root privileges, so:
sudo python3 startPC.py
That’s all. Here is a short movie to proof that it works!
Special thanks to my friend Michael who gave me the general idea of this solution.
Additionals:
- For remote control of Windows machine I recommend TightVNC. It works as a service on PC side and provides a viewer for remote control. It’s free and it has this advantage over regular RDP that it emulates you sitting in the front of computer, so Windows will not log you out when connection will be closed. It’s useful when you want to play remotely with Steam which doesn’t start before you log in. If you have Linux or Mac on the viewer side, you can use TigerVNC viewer to connect with TightVNC server.
- If you want to be able to remotely shut down you computer in case of failure (e.g. system hangs), you can change time when GPIO has a high status. Typically 4 seconds is enough. To do it, just change line 7 from 0.5 to 4 and save file as stop_pc.py
0 Comments