
Working in a pair, we designed SBMail, a connected mailbox that sends a notification with a photo on every new delivery. The goal: a simple, secure and accessible solution to track your mail in real time, wherever you are.
System architecture
The system relies on an ESP32-CAM paired with an infrared sensor (IR). When motion is detected (mail insertion), the ESP32-CAM captures a photo, uploads it to Firebase Storage and updates a real-time database.
On the mobile side, a Flutter app lets users:
- Sign in via email/password or Google (Firebase Auth)
- Receive live notifications (Firebase Cloud Messaging)
- Browse the delivery history
- Manage their linked mailboxes
- Unlock the mailbox remotely
Linking mailboxes via QR code
Each mailbox has a unique QR code generated from its identifier. On first use, the user can scan this QR code with the mobile app to automatically link the mailbox to their account. This avoids any manual entry and ensures a fast, secure pairing between the user and their hardware.
Firebase integration
The project combines several Firebase services:
- Realtime Database: links users to their mailboxes and detects the unlock action
- Storage: hosts the captured photos
- Cloud Messaging: sends the notification to the user
- Authentication: secure account management (users vs anonymous ESP)
Electromagnetic lock
To open the mailbox, a 12V electromagnetic lock (model S0837DL-B) is triggered through a relay connected to the ESP32. The ESP watches a variable in the Realtime DB and triggers the opening accordingly.

Challenges faced
The project wasn't without difficulties:
- Sending notifications required fine FCM configuration (tokens, topics...)
- Uploading the code to the ESP32-CAM was particularly tricky. Without the proper USB-to-serial shield, flashing was unstable or failed. Once the shield was added, the process stabilized
- Managing the timing between capture, photo upload to Firebase Storage and the real-time DB update took several tests
Result
SBMail is now functional and reliable. Every delivery is documented and viewable from a simple interface, and the mailbox can be unlocked from anywhere. This project let us master the Firebase ecosystem, deepen our Flutter skills and experiment with IoT in real-world conditions.
The system in pictures
Here is a look at our setup: