DIY Smart Mailbox Sensor That Alerts You When Post Arrives

· by Lukas Lang · 6 min read

DIY Smart Mailbox Sensor That Alerts You When Post Arrives

Waiting for the post to arrive no longer means peeking out the window every five minutes. In this guide you’ll build a DIY smart mailbox sensor using an ESP32 and a reed switch that fires off a notification straight to your phone the moment the letterbox lid swings open. The whole thing costs under £15 in parts, runs on batteries for months, and doesn’t need a cloud subscription of any kind.

How a Smart Mailbox Sensor Works

The circuit is almost embarrassingly simple. A reed switch is a small glass capsule with two magnetic contacts sealed inside. Bring a magnet close and the contacts close (or open, depending on the switch type), completing the circuit.

That “wake on change, then sleep again” cycle is the whole trick. It’s why the battery lasts for months instead of days.

What You’ll Need

ComponentApproximate cost
ESP32 dev board (ideally one with low deep-sleep current, e.g. FireBeetle 2 or TTGO T7)£6–10
Reed switch (normally open)£1
Small neodymium magnet£1
10kΩ resistorpennies
Battery holder (2× AA or 3× AA) or 18650 + holder£2–4
Plastic project box or IP65 enclosure£3
Silicone sealant / hot glue£1

One tip worth remembering: go for a plastic enclosure, never metal. A metal box turns into a Faraday cage and your Wi-Fi signal just dies inside it.

Wiring the Reed Switch to the ESP32

Five minutes, tops. Wire it up like this:

  1. One leg of the reed switch → GPIO4
  2. Other leg of the reed switch → GND
  3. 10kΩ pull-up resistor between GPIO4 and 3.3V

Lid closed, magnet holds the reed contacts together, GPIO4 reads LOW. Open the lid, the contacts spring apart, and the pull-up resistor yanks GPIO4 HIGH. That rising edge is your trigger, plain and simple.

Stick to an RTC-capable GPIO (GPIO4, GPIO32, GPIO33 all work fine) so the ESP32 can actually wake up from it while in deep sleep.

Powering the Sensor

This is where most builds quietly fail, so it deserves real attention. A stock ESP32 dev board in “deep sleep” can still pull 5–10 mA thanks to its onboard voltage regulator and power LED. That’s enough to drain two AAs in under a week, which defeats the whole point.

For long battery life:

Firmware That Sends the Alert

Below is a complete Arduino sketch built around ntfy.sh, a free push-notification service that needs no account whatsoever. Install the ntfy app, subscribe to a topic like your-mailbox, and anything published to that topic lands straight on your phone.

#include <WiFi.h> #include <HTTPClient.h>

const char* WIFI_SSID = “YOUR_WIFI”; const char* WIFI_PASS = “YOUR_PASSWORD”; const char* NTFY_URL = “http://ntfy.sh/your-mailbox-topic”;

#define REED_PIN 4

void setup() { Serial.begin(115200);

// Wake next time the lid opens (GPIO4 goes HIGH) esp_sleep_enable_ext0_wakeup(GPIO_NUM_4, HIGH);

// Connect to Wi-Fi (give up after 15s to save battery) WiFi.begin(WIFI_SSID, WIFI_PASS); unsigned long start = millis(); while (WiFi.status() != WL_CONNECTED && millis() - start < 15000) { delay(100); }

if (WiFi.status() == WL_CONNECTED) { HTTPClient http; http.begin(NTFY_URL); http.addHeader(“Content-Type”, “text/plain”); http.POST(“The post has arrived! Mailbox opened.”); http.end(); }

esp_deep_sleep_start(); // back to sleep until the next opening }

void loop() { // Never runs, deep sleep handles everything. }

Notification alternatives

Not a fan of ntfy? Same core logic, different messenger:

A Honest Limitation, and How to Fix It

A door-mounted reed switch fires every single time the lid opens, including the times you check an empty box out of habit. Most people just live with that, but if you actually want confirmation that mail arrived, bolt on a second sensor:

Whichever route you take, the ESP32 just checks both inputs on wake and only sends a notification when the mail-confirming sensor agrees something’s in there.

Weatherproofing Tips

Your mailbox lives outdoors year-round, so seal it up properly:

Troubleshooting Common Problems

Conclusion

A DIY smart mailbox sensor built around an ESP32 and reed switch is genuinely one of the more satisfying starter IoT projects out there: cheap parts, a tiny circuit, a result you’ll actually use every day. Start with the basic door-open alert, then level up with a confirmation sensor and Home Assistant integration once you’re comfortable. Once you feel your phone buzz the second the post drops through the slot, going back to checking the box by hand just feels absurd.

#ESP32#Smart Home#DIY Electronics#IoT#Home Automation