A homemade alternative to Wake on LAN? Yes please. - Other Embedded Platforms and Hardware Hacking
My need is simple, be able to turn my main computer on remotely to be able to retrieve needed files, or watch a film or tv show using plex. I don't own or am able to afford at the moment a full blown server (although I have finally made an investment into several SAS drives and a raid card) while also power usage is a concern to keep costs minimal.

I'm not sure how many here have tried using wake on lan either through a network or through using another machine connected on that local area network, but let me tell you - for me it has been nothing but a pain trying to get it to work consistently. I had the `wol` utility working fine, but only if the device you're trying to boot is on the same LAN as the machine you're on currently - so unless my phone was on the LAN as well, it wouldn't work. Now normally I am one for trying to hammer away trying all tricks to get the result I want, but instead a post I read on stackoverflow inspired me to think of an electrical solution instead of a software one.

On a motherboard there are two pins dedicated to the power switch on your front case I/O. All this switch does is close the circuit between these pins, allowing the motherboard to start all of its other, vastly more complex circuits. What can we use to remotely close these pins then? You guessed it, a raspberry pi. Using the GPIO pins we can simulate the power pins on the motherboard closing. To achieve this you need the following bits of hardware:

- A raspberry pi. In my case I used a raspberry pi zero W, so I can connect to wirelessly and because its form factor is small.
- A SD card to boot the pi off. I used Arch Linux ARM for the OS.
- GPIO pins. Normally you can get these pre-soldered when you buy a pi, in my case I didn't get a pi that had them so I had to buy them separately.
- An internal USB header to male micro B or USB A Female to plug a micro b cable in. To power the pi without having to leave the case open, nearly all motherboards have the feature to power usb devices while the machine is off.
- Jumper wires. I ordered a whole bunch off amazon because I'll probably use them in the future.
- Jumper wire splitters, so we can still use the power button on the case.

So in total, this hardware cost about 40 quid or so, the majority of the cost being the pi and sd card which you can use for other small software tasks as well.

The next thing we need to do is think about how we're going to use the pins to close the circuit. We only need to attach a ribbon cable to two pins, one to a ground pin, and one to a GPIO pin. Now we only have to know how to actually access these pins using our pi. I found this post which nicely details how to control the pins using the filesystem.

I quickly wrote up a script to do this nicely of course:

# wake


test ! -d "$GPIO" && {
    printf '%s\n' "No gpio directory found."
    exit 1

power() {
    # initialise pin
    test ! -d "$GPIO/gpio$pin/" && printf '%s\n' "$pin" > "$GPIO/export"

    # change direction of pin briefly to close power circuit
    printf '%s\n' "out" > "$GPIO/gpio$pin/direction"
    sleep 0.2
    printf '%s\n' "in" > "$GPIO/gpio$pin/direction"

shut() {
    # initialise pin
    test ! -d "$GPIO/gpio$pin/" && printf '%s\n' "$pin" > "$GPIO/export"

    # change direction of pin to close power circuit for longer
    printf '%s\n' "out" > "$GPIO/gpio$pin/direction"
    sleep 3
    printf '%s\n' "in" > "$GPIO/gpio$pin/direction"

case "$1" in

So as per the script I connected my positive pin 23 to the positive end of thesplitter wire and a ground pin to the negative end of the splitter wire, here's the results:

[Image: lkXJ2Ex.jpg]

So the workflow can be surmised as follows:
remote to home using dns provider-> access pi zero via ssh -> run script

In Action

A long boot time primarily because of the mobo boot firmware is slow, I have my systemd-boot screen and finally my 14tb raid pool has to spin up.

The only bug: If the pi hasn't been turned on and the pins initialised for some reason this is causing a short somewhere and the machine refuses to turn on when I just press the power button. I might put a diode in somewhere to stop this from happening.

Members  |  Stats  |  Night Mode