How a $3 ESP32 card turns your PC's power button into a remote switch—no Wake-on-LAN required

My home server runs more than a dozen services I use regularly for work and for my personal life. Wake-on-LAN is great when it works, but it isn't foolproof. Sometimes a BIOS update breaks your settings, the network card gets put to sleep, or the PC is completely offline. When WOL fails, someone has to physically push the power button on the PC. If I'm away from home, that can be a problem.
That is why I started working on an alternative using an ESP32 board that interfaces directly with the motherboard's power header.
How the ESP32 power button pusher works
GPIO to a header

Nick Lewis / How-To Geek
Your PC's power button isn't especially complicated. It is just a momentary switch that connects two pins on the front panel header. If you really want, you could turn your PC on by jumping those two pins using a screwdriver (but you shouldn't).
The ESP32 power button pusher works by replicating that function, except instead of mechanically pushing the button, the GPIO on the ESP32 "presses" it electrically. All you need are a few common parts and an optocoupler (ideally) or a relay.
Once the device is physically connected to my PC, the ESP32 connects to my Wi-Fi. From there, I can trigger a button "press" via a digital interface, like Home Assistant or even a webpage.
ESPHome makes this project very simple.
Though I haven't implemented it yet, I'm going to wire up a GPIO pin to the LED header too. That way, the ESP32 board will receive an input that can tell me whether the PC actually powered on successfully rather than leaving me to hope it worked correctly.
My ESP32 board will be powered by a battery backup, though you could power it via a spare USB header if you wanted to keep things tidy.
ESP32 beats Wake-on-LAN (WOL)
I've never had good luck with WOL

Patrick Campanale / How-To Geek
Every PC I've ever owned has been a little weird about its network adapters. Sometimes they get disabled by a fast startup setting, other times they wind up inappropriately deep sleeping when I don't want them to. Wake-on-LAN (WOL) is also not an option if the PC in question had a hard power loss, like a power outage —a problem that comes up fairly frequently for me. Whatever the specific circumstances, I don't fully trust WOL to work when I need it.
Simulating a physical button press circumvents those issues completely. It also allows me to do a few things that WoL can't, like force a shutdown by "long pressing" the button.
My ESP32 will run off a battery that will keep it active during brownouts and short outages, but it isn't strictly necessary. Any good power supply that works with your ESP32 will be adequate.
Building the ESP32 button pusher
Your shopping list is short

To get started, there are several things you'll need:
-
An ESP32 dev board
-
An optocoupler or a relay
-
A few resistors (which may be applicable, depending on your setup)
-
Wires
-
A breadboard (for prototyping)
I don't have an optocoupler available at the moment, so I'm using a relay. That isn't a problem, and it is audibly clicky—something I actually enjoy. I also used a breakout board; it isn't necessary, but it does make it a little easier.
The output of the ESP32 needs to connect to the relay so that you can control it. Test that this works correctly before you connect it to your motherboard. My specific relay calls for power, a switch, and a ground. The output has Normally Closed (NC), Normally Open (NO), and Common (COM). In my case, I want the relay to be normally open, which means power is only applied to the motherboard pin when the relay itself receives a signal. So, I attached wires to COM and NO.
If you accidentally connect to NC instead of NO, you'll find that your motherboard behaves like someone is constantly holding the power button. If you have a multimeter handy, NC and COM will have near zero resistance or beep if you use the continuity check mode. NO and COM will not.
Once that was done, I needed to flash the board using the code I cajoled Claude into producing. It has one switch function, which is a 300ms press to turn the PC on, and a second 5500ms hold to force the PC to shut down. With the firmware flashed, the only thing to do was to power up the ESP32, connect it to an old motherboard to test it, and verify that everything worked correctly.
The final step, which I have yet to complete, is integrating the entire thing into my Home Assistant setup. Eventually, I'll just be able to press a button on my phone to turn my server PC on and off.
ESP32 is a cheap, reliable way to control your PC
For less than $20 in parts and about 45 minutes of tinkering, you can create a setup that will work more reliably than Wake-on-LAN and give you more control.
If you want to expand the functionality, you can read output from the power LED pins to determine the PC's state or wire up another relay (or a single, more complex relay) to the restart pins.
If you don't have an ESP32 board handy, don't worry—it isn't strictly necessary. A Pi Pico W or a Pico 2 W will work just as well for this project, but your code and pin outs will be a little different.
