An ESP32-based device that simulates a PC power button, allowing remote control and automatic startup after power outages.
- Remote PC power control
- Automatic wake-up based on network device monitoring
- Web interface for configuration and management
- REST API for automation and integrations
- ESP32 Smart PC Power Button
- Features
- How It Works
- Hardware Requirements
- Wiring Diagram
- Software Stack
- Quick Start
- Installation
- General Configuration
- REST API
- Home Assistant Integration Example
- Future Improvements
- License
The ESP32 connects to your local network and monitors selected devices (any wifi device in network).
When Auto Power On is enabled:
- The ESP32 periodically checks whether the monitored device responds to network requests.
- If the device becomes reachable while the PC is still off, the ESP32 triggers the motherboard power button signal using an optocoupler.
- The PC powers on automatically.
This allows the computer to recover automatically after power outages when restoring the last state and WoL don't work.
When Auto Power On is disabled, the device behaves like a simple Wi-Fi-controlled power button that can be triggered through the Web UI or REST API.
Note
Because the PC's status is checked via the network connection, the Auto Power On feature may cause an endless reboot loop if there are network issues on the PC's end.
- ESP32‑C3 SuperMini (or compatible ESP32 board)
- PC817 optocoupler
- 330Ω resistor
- Jumper wires
- Optional breakout board
- Optional enclosure
Note
Some ESP32‑C3 SuperMini boards have weak Wi‑Fi signal stability because the antenna is placed very close to other components. A simple fix is to solder a ~3 cm copper wire to the antenna pad indicated in the diagram.
Some boards also lack an exposed reset pin, so you may need to solder directly to the reset button pads.
The full wiring diagram and assembly example are shown below.
- MicroPython -- ESP32 firmware
- SolidJS -- Web interface
- Node.js -- frontend build system
- Flash MicroPython to the ESP32-C3.
- Download latest available version on Releases page.
- Upload the contents of the
esp32directory to the device. - Edit
esp32/settings.pyand set your Wi-Fi credentials. - Restart the ESP32.
- Open the ESP32 IP address in your browser to access the Web UI.
The device is now ready to control your PC power button.
Download firmware for ESP32‑C3:
https://micropython.org/download/ESP32_GENERIC_C3/
You can flash it using esptool or:
https://adafruit.github.io/Adafruit_WebSerial_ESPTool/
The latest available version can be found on the Releases page.
Upload the contents of the esp32 directory to the device.
A convenient method is using Thonny IDE:
Setup guide:
https://randomnerdtutorials.com/getting-started-thonny-micropython-python-ide-esp32-esp8266/
Add wifi.txt with WiFi credentials:
YOUR_WIFI
YOUR_PASSWORDYou can also edit settings.py to set GPIO pin.
# esp32/settings.py
# GPIO pin connected to optocoupler
s_pin = 4After uploading the files, restart the ESP32.
The device will connect to Wi‑Fi and print the assigned IP address in the serial console or find the device by its hostname esp32-pc-button.
Open the address in your browser to access the Web UI.
| Field | Description | Notes |
|---|---|---|
auto_power_on |
Automatically powers on the PC when the monitored device becomes available | |
host_ip |
IP address used to check whether the PC is online | Must be a valid IPv4 address |
target_ip |
IP address of the device being monitored | Must be a valid IPv4 address |
heartbeat_interval_s |
Time interval between connectivity checks | Not recommended to set lower than 30 seconds |
retry_delay_s |
Delay before retrying power-on if the PC did not start | Should be higher than PC boot time (e.g., 1.5–2×) |
status_sample_size |
Number of consecutive checks to confirm online/offline status | Range: 1–10; higher values reduce false positives |
allow_power_retry_limit |
Enables limiting the number of power-on retry attempts | |
power_retry_limit |
Maximum number of retry attempts | Required when retry limit is enabled; minimum: 1 |
Access the API through the IP address assigned to the ESP32.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/config |
Get current configuration |
| PUT | /api/config |
Update configuration |
| GET | /api/signal |
Trigger power signal |
| GET | /api/retry_clear |
Clear retry counter |
| GET | /api/ping_status |
Get device monitoring status |
| GET | /api/sys/reboot |
Reboot ESP32 |
| GET | /api/sys/info |
Get system information |
| GET | /api/sys/logs |
Get system logs |
Example REST command configuration:
rest_command:
pc_power_on:
url: "http://ESP_IP/api/signal"
method: GETExample button:
button:
- platform: template
buttons:
pc_power_button:
friendly_name: "Power PC"
press:
service: rest_command.pc_power_onPlanned ideas and possible future enhancements:
- Wi-Fi setup mode (initial configuration through a temporary access point)
- Wi-Fi reset functionality to clear saved credentials and re-enter setup mode
- Add the ability to configure multiple devices for control.
- Allow monitoring multiple network devices simultaneously
- Add MQTT support for deeper Home Assistant integration
- Improve network monitoring logic (custom intervals, retries, thresholds)
This project is licensed under the MIT License.
See the LICENSE file for details.



