# Building a Real-Time Power Outage Monitor with ESP32 and Slack

The moment of realization happened in Singapore. I was thousands of miles away from home, enjoying a trip, when I went to check my home CCTV footage through my phone. The screen stayed black. "Connection Failed."

The internal monologue of a developer immediately goes to the worst-case scenario: *Did the router die? Is there a break-in? Did the server crash?*

The reality was much simpler, yet equally frustrating: a power cut. The cameras ran on their internal batteries until they hit 0%, leaving me in a complete information blackout. I didn't know if the power was out for ten minutes or ten hours.

I promised myself I wouldn't leave for another trip without a "Heartbeat" from my home in Amritsar.

### The Solution

I needed a non-invasive system (no cutting 220V mains wires), resilient to inverter switchover gaps, and capable of sending instant notifications.

I chose the **ESP32** for its built-in Wi-Fi and low power consumption. By pairing it with a Slack Webhook, I created a device that "shouts" the second the grid fails.

### The Hardware Stack

To keep things modular and "plug-and-play," I went with:

*   **ESP32 DevKit V1:** The brain of the operation.
    
*   **USB-TTL Converter:** This acts as the sensor. It brings the 5V USB signal down to a safe 3.3V for the ESP32 to read.
    
*   **1000µF Capacitor:** Essential for bridging the 20ms gap during inverter switchover. This prevents the ESP32 from rebooting during the transition.
    
*   Female-to-Female jumper wires
    
*   Some USB data cables
    

### Engineering the "Flicker Filter"

One of the biggest hurdles was electrical noise. GPIO 34 on the ESP32 is an input-only pin and can act like an antenna. Without a solid ground reference, the signal "flickered" between ON and OFF.

I solved this with a two-pronged approach:

1.  **Grounding Geometry:** Moving the ground wires to the same side of the board to stabilize the reference voltage.
    
2.  **Software Debounce:** I implemented a 3-second delay in the code. The system verifies that the power is *actually* out before sending a Slack alert, preventing false alarms from minor grid fluctuations.
    

### Watch the Journey

I documented the entire process—from navigating the local electronics markets in my city to the final "Production" test where I manually tripped the MCB.

*   **Watch the Documentary:** [YouTube - Making my first Electronics project](https://youtu.be/WmGZCAdeHMY)
    
*   **Get the Code:** [GitHub - esp32-power-alert](https://github.com/ravgeetdhillon/esp32-power-alert)
    

### Closing Thoughts

Engineering isn't just about writing code for a Jira ticket; it's about solving the small, personal anxieties of life through technology. Now, when I’m on vacation, I’ll know exactly what’s happening at home. Not because I’m checking a camera, but because my home is talking to me.

*If you're interested in building this yourself, feel free to reach out or check out the repository!*
