How I Taught My Homelab to Self-Heal with an ESP32
29 April 2026

Power outages are a nightmare for servers, especially in a homelab. Unlike data centers, which have massive power backup plans, budget friendly homelabs often rely solely on small UPS units. Residential areas also frequently experience unplanned power outages with little information about when the power will return, whether it will be an hour or more.

Small UPS units are typically only designed to give a brief window of power to a PC, allowing it to turn off gracefully without data loss. However, homelabs present a special case since we are not sitting in front of the server all the time. We could be far away, sleeping, or busy with something else. If not mitigated properly, our entire homelab data could vanish due to an improper server shutdown.

Solution

mermaid
graph TD
    subgraph Power_Outage [Power Outage]
        direction TD
        A[Power goes out] --> B[ESP32 turns off]
        B --> C[Server cannot<br>reach the ESP32]
        C --> D[Server shuts down]
    end

    subgraph Power_Restoration [Power Restoration]
        direction TD
        E[Power comes back] --> F[ESP32 turns on]
        F --> G[Send WoL magic packets<br>to all given IPs & MACs]
        G --> H[Server turns on]
    end
    
    classDef outage fill:#ffe6e6,stroke:#ff6666,stroke-width:2px,color:#000;
    classDef restore fill:#e6ffe6,stroke:#66ff66,stroke-width:2px,color:#000;
    
    class A,B,C,D outage;
    class E,F,G,H restore;

Setup

You will need the following:

  • Server
  • ESP32
  • UPS
  • Power

See the diagram below for how to set everything up. The yellow line represents the power cable.

SolutionSolution

Code

Check the hilmoo/homleb-iot/wol GitHub repository for the code

On this page