Pi Zero IoT Mailbox Sensor
Recent Updates
- Feb 1, 2026: Lowered the detection threshold to 10g for better sensitivity as it was missing a few "drops"
- Jan 15, 2026: Added temperature compensation logic, the sun (when it makes an appearance in Scotland) is directly on the garage door
- Jan 8, 2026: Initial build and deployment
Overview
My letterbox is in my garage, and mail lands in a hanging wire basket to keep it away from the Scottish elements. I've somehow ended up with a silly number of various Raspberry Pi models, most of which I don't use much anymore, but this project turned a Zero 2W into a weight-based mail detection system using load cells and webhook notifications. Sounds fancier than it is, it's totally unnecessary, but I like it, and it's been a ton of fun. Any excuse to get the soldering iron out.
The Problem
Walking to the garage to check for mail only to find it empty gets old fast, well, it's only 10 steps away, but still, that's the excuse I am using for a bit of tinkering and messing around with the Zero. I wanted a simple notification system that would alert me when mail actually arrived, without relying on motion sensors that could be triggered by spiders or temperature changes, although I do want to make a temp-based one as well. Motion sensors would be cool, but honestly, my garage is an arachnaphobes nightmare..
Hardware Components
- Raspberry Pi Zero 2W - Low-power monitoring controller (£15)
- 5kg load cell + HX711 amplifier - Precise weight detection (£5 total on eBay). Worth noting the HX711 runs at 3.3V, not 5V - not an issue since the Pi Zero has a dedicated 3.3V pin.
- Metal basket - Already had this hanging in place to catch mail
Physical Setup
The load cell acts as a "smart link" between the garage door mount and the hanging basket. Every gram of mail that lands in the basket gets measured. Mounting it in the most efficient way had me drawing up a few plans, in the end I used M5 eye bolts screwed into the threaded holes at each end of the load cell.
The wee Zero
and the load balancer
Software Stack
- Python - Main monitoring script and calibration tool
- HX711 library - The interface for the load cell amplifier
- RPi.GPIO - GPIO pin control
- HTTP webhooks - Notifications to my HomeTown dashboard
- JSON logging - Delivery history with timestamps, because why not..logs are everything !!
Calibration Process
Getting accurate weight readings required a wee bit too and fro to get it properly calibrated. I used an empty can (Irn-Bru of course) that was about 15 grams, which gave me a baseline to work with. The calibration Python script averages 5 readings for better accuracy:
#!/usr/bin/env python3
import json
import time
from hx711 import HX711
import RPi.GPIO as GPIO
# GPIO pins
DOUT_PIN = 5 # Physical pin 29
SCK_PIN = 6 # Physical pin 31
def calibrate():
hx = HX711(DOUT_PIN, SCK_PIN)
# Get baseline (empty basket)
print("Remove all items. Press Enter...")
input()
baseline = hx.get_weight(5) # Average 5 readings
# Calibrate with known weight
print("Place 500g weight. Press Enter...")
input()
weighted = hx.get_weight(5)
# Calculate factor
factor = 500 / (weighted - baseline)
# Save calibration
data = {
'baseline': baseline,
'factor': factor,
'date': time.strftime('%Y-%m-%d')
}
with open('calibration.json', 'w') as f:
json.dump(data, f)
print(f"Calibrated! Factor: {factor}")
return data
if __name__ == "__main__":
calibrate()
GPIO.cleanup()
Detection Logic
The monitoring script continuously reads the load cell and compares against the baseline. When weight exceeds the threshold (10g) and remains stable for 2 seconds, it triggers:
- Sends HTTP webhook to my 'HomeTown' dashboard
- Logs it to a JSON file with timestamp and (pretty accurate) weight
- Has a cooldown period (5 mins) to prevent duplicate alerts
- Recalibrates the baseline every 24 hours to compensate for temperature changes, four seasons in a day and all that
Configuration
All settings are managed through a pretty simple config file, this way if I want to adjust thresholds or notification methods, I don't need to touch the main code:
# Detection Settings
DETECTION_THRESHOLD = 10 # Grams
READING_INTERVAL = 0.5 # Seconds
COOLDOWN_PERIOD = 300 # 5 minutes
BASELINE_RESET_HOURS = 24 # Auto-recalibrate
# Notifications
WEBHOOK_URL = "http://192.168.1.91/mailbox/alert"
HTTP_TIMEOUT = 10
Dashboard Integration
The webhook hits my HomeTown dashboard (running on Dullbox), which displays the current mailbox (basket) status and logs recent deliveries. The dashboard shows:
- Current status (Empty / Mail Detected)
- Last delivery time
- Weight of last delivery
- Delivery history for the past week
Challenges Solved
False Positives
Wind vibrations caused false triggers from the get go, the North Sea is about 150m away and it's a windy wee town. So this is why I put in logic requiring the weight to be stable for 2 seconds before alerting (if the reading fluctuates, it's ignored).
Temperature
The load cell readings drift slightly with temperature changes (garage gets hot in summer, sometimes, and freezing in winter, always, but recently predicting the weather has been like reading tea leaves). It's pretty minimal, but the automatic baseline recalibration every 24 hours compensates for this.
Power Supply
The garage has mains power, so the Pi Zero runs off a standard USB power adapter. At ~100mA draw, it's basically nothing on the electric bill - probably costs pennies per year to run. I might try hooking up a tiny solar panel though to see if the Zero can handle it.
Current Status
The whole setup has been running well the last couple of weeks. It's a shame 99% of the mail I get is junk, but the recyling bin is right by the garage so no worries. I'm pretty happy with the logic to avoid false positives, so far so good anyway.
What I Learned
This was my first proper GPIO project on the Pi, and it taught me a lot about dealing with analog sensors, real world environmental impact on physical hardware, and the importance of proper calibration, which can be painstaking, but it's so essential for this project. I'm pretty keen to keep expanding on this, it was a ton of fun so.
Next Steps
- SMS notifications for important deliveries
- Historical analytics - mail volume patterns, postie arrival times
- Machine learning to detect package vs letter based on weight patterns
- Figure out a way to detect bills and automatically fire them into the sun
Resources
I'll host a full write-up of this on GitLab soon.