I have a PC that I mainly use to run heavy jobs, like machine learning tasks, or heavy processing tasks. For some reason, it sometimes crashes and I can’t restart it remotely. I can’t debug this crash easily as the screen shows a black screen after the crash. And to be honest, after several hours trying to figure it out, I don’t have time for this.
So, the solution is simple: I don’t care if the PC crashes. I just want to be able to hard reboot it, but remotely, just like if I pressed the power switch for 5s.
PC motherboards have a connector for the front panel, which has multiple pins. Two of those pins are for the power switch, another 2 are for the reset switch.
The idea is to build a small smart device, that can simulate a button press (or hold) instead of doing it manually. I have some ESP8266 devices lying around, which are perfect for this job: low-power, small, a lot of GPIOs and easily programmable with the Arduino platform.
The power switch is just a Normally Open switch, which connects the two pins while pressed. You can’t connect direcly the GPIOs of the ESP8266 to the power switch pins of the MB header, the voltage on those pins are generally powered with a voltage of 5V, the ESP8266 is 3V, and the goal here is to let the current pass through the pins. An idea would be to use a Solid State Relay, but you can’t power it from an ESP3266 and it’s way overkill for this job. A better idea is to use an optocoupler like the PC817 to act as a switch.
Here is the schematic I designed:
Good news is, I can still use the physical switch, it’s just like if there were two switches instead of a single one.
Here is how it looks like in my PC, it’s not pretty as I only did the wiring on a protoboard for now, but it works, and I even have placed the ESP8266 (Node-MCU) USB port at the back of the PC Case, like all other ports.
The Arduino program will be an embedded web server, with 3 urls: power_on, power_off and restart. This allows me to control it easily, using a web browser, an iOS Shortcut or whatever I like to automate the process.
The /power_on command simulates a 500ms press on the switch
The /power_off command simulates a 6s press on the switch
The /restart command simulates both a power_off command, waits for a second and then simulates a power_on command.
Because I also have a home VPN, I can now access my computer remotely, but also power it on and off at will. This is not only useful when the PC crashes, but it also allows me to save money by turning it on without having to rely on the Wake On LAN feature!