It's so exciting! I have no idea why, but getting something new is definitely noteworthy. It may be a letter from your great aunt Carol, it could be those radio parts you ordered from somewhere overseas, or maybe just the latest edition of the Hometown Gazette. Who knows? Who cares?!? It's ALWAYS interesting! Heck, you've already been tracking the package from who even knows where, through all the processing plants, trains, planes and automobiles, so why not ensure you get the most important notification of all; your mailbox!
The solution seems obvious and was inspired by the mailbox flag, 📬. The mailbox already has a feature, the flag, which allows you to notify the mail carrier that you have placed mail in the mailbox to be picked up. So why not have a system in place to notify you of the same situation?Considerations
The standard mailbox is a simple device, and requires no power to work. As a result, there is no mains power anywhere near the mailbox. This means I needed a power efficient solution that can run entirely on battery and use a solar panel to recharge.
This is where the Notecard and Notecarrier-AL really shine. First, the Notecard can idle at ~8uA and can disable/enable the host microcontroller using its configurable interrupt mechanism. Secondly, the Notecarrier-AL has a solar charging circuit and comes prepopulated with two JST connectors used to connect a battery along with a 4-7V solar panel.
The major hurdle in IoT-izing your mailbox, is that it's just out of reach of your home Wi-Fi router, which pushes us into the cellular realm. If we are being honest, the idea of paying a monthly cellular data charge diffuses most ideas in this category (beyond the proof-of-concept stage), because the novelty is not worth the cost. This is where the Blues Wireless cellular model has been a game changer. Now you can just buy the device and know it will work for 10 years with no monthly fee.
Given the power of AI and availability of myriad exotic sensors, there are so many ways to know when the mail has arrived, along with varying levels of certainty, it is truly mind-boggling. That being said, I chose to keep it simple.
When the mailman opens the door to the mailbox, inserts mail, then closes the door, it naturally jostles the mailbox. The jostling is captured by the Notecard's IMU sensor, which then causes the host MCU to wake up and report the event to Notehub.io.
What good is it that a machine knows when I have mail, if I do not? Uhmm... None. Fortunately, there is a simple Notehub integration for Twilio.Dead Simple Implementation
Amazingly, the Notecard/Notecarrier-AL combination is capable of doing this without even requiring an MCU! The Notecard can be configured using the Notecard Playground at the Blues Wireless Developer website. Issue the following commands and your Notecard is ready to go!
Direct your Notecard to your Notehub.io account:
Optimize the battery consumption based on charge:
// Optimize voltage variable behaviors for a LiPo battery
// Configure IMU sensitivity (3.904G)
// Queue a Note based on motion detection
// Sync based on motion detection alert
That's it folks! This will allow you to be alerted of motion events at a frequency no greater than once every 3 hours. In theory, you would get one event per day, but the throttling should insulate against a rain storm or squirrel attack.Adding a Raspberry Pi Pico for Manual Reset
Taking another queue from the mailbox flag 📬, I decided to use a mechanical input (in this case, a button), to indicate whether or not I have addressed an alert. Just as with outbound mail, you can continue to add pieces of mail, however you would not raise additional flags to notify the mail carrier. Only after the mail carrier has picked up the mail and lowered the flag, would you again need to raise the flag to send a new alert to the mail carrier.
Originally, I had anticipated storing the button state on the Notecard with a card.attn payload coming from the Pico. However, I quickly realized this solution requires the Pico to be enabled, which completely defeats the purpose. Fortunately, I stumbled upon a soft-latching circuit from EEVblog.
I was able to modify it for my use case, and I dubbed it the Snooze Button for Blues Wireless Notecard Alerts. The snooze circuit runs directly from the battery power, so it doesn't get disabled along with the host MCU. When active (mail delivered), the circuit will consume about 630uA, and only 3.6uA when the circuit is in stand-by mode (awaiting mail). Therefore, the snooze button makes an ideal compromise between complexity and efficiency.
With the snooze button in place, now the Pico can check to see if an alert has already been sent, or if a Note should be generated. Now, thanks to the Pico and less than 100 lines of code, I will only receive a single alert until I have had an opportunity to check my mailbox. Perfection!
It's worth noting, although the Pico is a power conscious device, the Notecard enables you to minimize the power profile of ANY host device by using the ATTN pin to disable it (to learn more about this pattern, visit the Blues Wireless Low Power Design Guide). As with this project, you can enjoythe additional computational complexity, without having to use any more battery than necessary.Mailbox to Pocket with Twilio
The last leg of the journey is from your mailbox to your pocket.
With the work that has been done so far, the mailbox is already generating an event that is going up to the cloud, however it's not doing much else. Fortunately, Notehub is designed to be a routing hub, which connects to nearly any other web service. The work to connect Notehub to Twilio was trivial when following the Notehub integration for Twilio. The guide walks you step-by-step through the entire setup.
Now, every Note (event) sent from my mailbox will be routed as a text message to my phone.A Quick Recap
When mail is delivered to the mailbox, then the mailbox is jostled. The jostling triggers a "motion event" on the Notecard. As a result, the Notecard wakes up the Raspberry Pi Pico. The Pico will check to see if the snooze button is active. If the snooze button is active, then the Pico will request to go back to sleep. If the snooze button is inactive, then the Pico will activate the snooze button and queue a Note to the Notecard for immediate delivery. The Notecard then sends a Note to Notehub. When the Note arrives at Notehub, it is forwarded along the predefined Twilio route. Finally, Twilio sends an SMS message alerting me I have mail in my mailbox. Huzzah!