Yet Another Mailbox Sensor Question (YAMSQ)™️

I want to build a mailbox sensor and I have looked at other projects on here, but most of the projects I have seen use a motion sensor or reed switch for detection. However, if the door isn't closed properly it might not trigger the 'closed' state, or if someone opens and closes the mailbox it causes a false positive. I have seen some people suggest a camera with mail detection AI, but that seems overkill for this application.

Instead, I was wondering if a simple IR beam break sensor might work. But a reflector on one side of the mailbox inside walls and the TX/RX on the other. While a piece for mail blocks the IR beam, the switch state would be 'on' indicating there is mail in the box. ESPHome on a battery powered XIAO ESP32C6 to run it. Anyone have any input on this approach? Am I missing something glaringly obvious?

Would the IR be sensitive to heat from the sun on the mailbox? Causing it to not detect?

Then you might need two or more sets (one horizontal, one vertical) for the two ways mail can be placed in the box, Then there is also accounting for small items that can be placed in away that misses the sensor(s) totally (to far back or to far forward).

With an IR beam. You won't need a mailbox sensor. You can just check for mail each day when you go to replace the battery.

Good thoughts. Our mailbox is a wooden box with a slot on top, I think the design of it would protect the sensor from direct sunlight. Indirect sunlight may come from the top when the lid is open. Since the mail drops down in the box, I think putting the sensor towards the bottom would catch even small mail. I think im going to pull the trigger and give it a shot.

Thats was my concern as well. Maybe I could only fire the sensor briefly every 5 minutes or something to extend battery life? Or do you have a better suggestion?

Deepsleep will improve battery life.wood is better than metal if decice is inside. How far from box to home? Show a pic of mailbox.

Mailbox is on the exterior of the house, range should not be an issue.

Connecting it to mains, or a car battery?

Seriously they have to lift the lid on that to put the stuff in. As long as you remember to drop the lid every day, use that.... A little contact switch and no battery drain from the IR sensor.

Yeah, the mail carrier doesn't always close the lid.

So the beam break sensor idea is unworkable for a battery powered device?
Thats fair, if it's not feasable, it isn't. Thanks for the feedback.

A push button for the postman to press when they deliver mail?
Sorta a reverse mail pickup flag, for mail dropped off?
A box of chocolates occasionally can be a great motivation for the postman to press it. Of course a passer-by can also press it, but then you could monitor the postman presence by a NFC tag on their mailbag, but isn't this a little onerous compared to just checking the mailbox, or the postman knocking on your door because they will get a smile and thank you and make it a less lonely job?

So true, and for countless thousands that have valiantly tried to get an ESP to work in low power modes and failed miserably, I commiserate. Maybe something less thirsty such as a nRF52840 may be an alternative?

This mailbox monitoring subject comes up so frequently that maybe it should be the subject of a FAQ or ESPHome example project.

We often have different mail carriers. I feel like there should be a reliable way to detect the presence of mail in the box in an energy efficient way. I understand that yes I could just go look at the mailbox, but this is just a fun challenge for me.

One misses the local Radio Shack/Tandy store, where a monthly free battery club card was a ploy to get you into their stores. Would have been ideal for this project if you could make the battery last a month instead of just a few days.

Wait, could we ask the mailman to replace the battery for us when it goes flat? Yeah/naah.

Disclaimer: At my previous residence, the mailbox was a large distance from the house, at the end of a very steep driveway. We trained the postman and delivery folks to use the back entrance (which was level with the house as we lived on a steep sloping corner block with a stepped multilevel house) as an option to save them the steep climb when delivering parcels. At the current premises, the mailbox is free standing out the front on a level block - no more breathless climb, just to check for mail. I seriously considered building a similar project, with solar or battery for power, and instead solved the issue a different way. I painted the inside of the mailbox so you could easily spot anything inside, and replaced the back flap with a clear perspex cover. I can just glance from the house or when I get home as I pass by and see if anything is in the mailbox without having to stoop and lift the cover. I don't need to know when anything was delivered to the nanosecond - just that something is in it. I can now do that visually. If my eyesight fails as I get older, a pair of binoculars, or a zone sensitive movement tracking camera trained on the letterbox may be an option.

I do miss radio shack.

They always open the lid.
You have to go to the box to get the mail, you can close it...

The switch/lever/flap combo positioned inside the box triggered by mail being placed through the slot would work. Think like the garage door position switches (older units) for closed/open.

I do like that idea, like a roller switch on way in? I'm looking for a solution that can actually detect the presence of mail in the box. Not infer that that the mail is still there because the door was opened 5 minutes ago. Does that make sense? Maybe trigger it by weight?

Yes on the roller switch, something to work on. Weight would be harder to determine (think postcard or ad flyers versus larger weight envelops/packages). So IR beam T/R might work in that box, I see it might be under a porch covering. You could put a solar charging for a battery device into the mix.


You could modify the box so lid tends to close if not supported by hand. Then you could use a 433mhz device with a reed switch. Cell in that would last > year unless you get 20 mailbox deliveries.
Our postal serivice has gone to the dogs. Only get deliveries once a week now.

I've gone down this exact rabbit hole and built a few prototypes using different sensors, from PIR to reed switches, and each had its shortcomings. As you mentioned, PIR relies on heat changes (which completely messes up the readings in a mailbox environment), and reed switches depend entirely on the lid closing perfectly. I also considered broader options like LiDAR and ultrasonic sensors, but ruled them out immediately due to environmental factors and the risk of making the setup unnecessarily complex.

I ended up settling on a ToF (Time of Flight) sensor that measures the distance across the mailbox, and it works flawlessly. I configured a baseline distance for when the mailbox is empty, and since that distance changes depending on how much mail is inside, I created a template sensor that calculates exactly how full the mailbox is from 0 to 100%. It's incredibly reliable, keeps the complexity down, and completely eliminates false positives.

This is what I am looking for! What hardware did you end up using?