← Projects
electronics beginner Jul 15, 2026 ◑ 3 views ◯ 5 min read

Build a Battery-Powered ESP32 Smart Mailbox Notifier

Build time: 2-3 hours
Tools needed: None required
Parts List
esp32mailboxreed switchdeep sleepnotificationbattery poweredhome automationdiy

A smart mailbox notifier solves an annoyingly common problem — walking out to check an empty mailbox, or missing a package delivery notification because you weren't watching a doorbell camera app. This build uses a simple reed switch or door sensor on the mailbox, paired with an ESP32 running on battery, to send a notification the moment the mailbox opens.

Why This Approach Over a Commercial Smart Mailbox Sensor

Commercial mailbox sensors exist, but they're often expensive for what's fundamentally a simple job, tied to a specific app/cloud service, and not something you can easily customize (multiple mailboxes, custom notification logic, integration with a broader home automation setup). This build costs a fraction of the price and integrates directly with whatever notification system you already use.

Parts List

ComponentNotes ESP32 dev board (low-power variant preferred)Since this runs on battery outdoors, power efficiency matters more here than raw performance — any standard ESP32 works, but boards specifically designed for low deep-sleep current draw last longer between charges Magnetic reed switchThe same type used in home security door sensors — one half mounts on the mailbox door, the other on the frame, and the circuit opens/closes as the door moves away from/toward the magnet LiPo battery + charge boardSized based on how often the mailbox opens and your deep-sleep power draw — a mailbox that's checked once daily needs far less capacity than a busy multi-unit box Weatherproof enclosureEven inside a metal mailbox, the electronics need protection from moisture and temperature swings — a small weatherproof project box is worth the few extra dollars Optional: small solar panel + charge controllerFor a mailbox in reasonably sunny placement, this can make the whole system essentially maintenance-free

How It Works

The reed switch is wired to an ESP32 GPIO configured to trigger a wake-from-deep-sleep event. The ESP32 spends essentially all its time in deep sleep, drawing negligible current, and only wakes when the mailbox door's motion physically breaks or makes the magnetic contact — at that point it wakes, connects to WiFi, sends a notification, and immediately goes back to sleep. This event-driven wake pattern (rather than periodic polling) is what makes long battery life practical here, since the ESP32 is essentially off except for the few seconds around an actual mailbox event.

Wiring

Firmware

#include <WiFi.h> #include <HTTPClient.h> #define WAKE_PIN GPIO_NUM_33 // must be an RTC GPIO capable of EXT0 wake RTC_DATA_ATTR int bootCount = 0; void sendNotification() { WiFi.begin("your-ssid", "your-password"); int attempts = 0; while (WiFi.status() != WL_CONNECTED && attempts < 20) { delay(500); attempts++; } if (WiFi.status() == WL_CONNECTED) { HTTPClient http; // Any notification service with a simple HTTP trigger works here — // a home automation webhook, a push notification service API, etc. http.begin("http://your-home-server/api/mailbox-alert"); http.POST("{\"event\":\"opened\"}"); http.end(); } } void setup() { bootCount++; esp_sleep_wakeup_cause_t wakeup_reason = esp_sleep_get_wakeup_cause(); if (wakeup_reason == ESP_SLEEP_WAKEUP_EXT0) { sendNotification(); } // Configure wake source for next sleep cycle esp_sleep_enable_ext0_wakeup(WAKE_PIN, 0); // wake on LOW — matches pull-up config esp_deep_sleep_start(); } void loop() { // never reached — everything happens in setup() after each wake }

The pattern here is deliberately different from a typical Arduino sketch — there's no ongoing loop(), because the whole point is the ESP32 spends its life asleep and only briefly wakes to handle one specific event before immediately sleeping again.

Notification Options

MethodNotes Home Assistant webhookIf you're already running Home Assistant, a simple webhook automation can trigger a push notification, and gives you a full event history/log for free Push notification service (Pushover, ntfy, etc.)Direct HTTP POST to a notification service's API, no home automation platform required Simple SMS/email via a scripting serviceWorks, but generally slower and less immediate-feeling than a push notification

Extending: Package Detection

The basic build tells you the mailbox door opened — it doesn't distinguish "mail was delivered" from "you checked the mailbox and it was empty." A few ways to add that distinction:

Battery Life Expectations and Tips

This is a small project with an outsized quality-of-life payoff — a notification the moment mail arrives, instead of a daily "walk out and check" habit, for the cost of a few cheap components and an afternoon of setup.