Is your mailbox at the end of a driveway? Or located somewhere in an apartment complex or campus? Have you ever had to make a "special trip" to go check the mailbox only to find out it's empty...GRRR! Now checking the mail just got a little easier.
The Mailbox Assistant is a system of systems that consist of the following: an Arduino (and components), a Raspberry Pi, Alexa and Heroku.
How it works.
- The User asks Alexa to open the Mailbox Assistant and check their mail.
- The Alexa skill makes a request to a RESTFUL API on Heroku.
- The API processes the request and subscribes to a topic using MQTT.
- It then makes a request to MongoDB database and retrieves the latest status that was publish.
- Alexa then notifies the user of their status.
- An Arduino powered device located inside of the mailbox is used to determine whether or not mail is present.
- The status of the message is transfer over Bluetooth Low Energy (BLE) to a Raspberry Pi.
- The Raspberry Pi publishes the state of the mailbox to a user specific MQTT topic.
- Arduino 101
- Xbee USB Adapter (Optional)
- XBee S2C Zigbee RF Module (Optional)
- LED (Optional)
- USB External Battery Pack
First, let me start by saying this device is intended to go inside of a mailbox. The reason why it is on a breadboard is purely for me to explain the interconnectivity. Secondly, I wanted an Arduino device that had a Bluetooth capability. That way I could check the status of my mailbox using a Bluetooth enabled device (e.g., phone, tablet, etc.). If that is not a desirable feature, then a device other than the Arduino 101 can be substituted.
Next, after analyzing a couple of sensors I chose the Ultrasonic proximity Sensor over an Infrared and Touch sensor. Reasons being, that most mail comes in white envelopes, so my assumption was that the infrared sensor would have trouble detecting an item. Moreover, the touch sensor usually needs a certain amount of weight before the sensor is trigger. If someone was to receive a single postcard, my assumption was the sensor would not detect the item. FYI, I did not test these assumptions so they could be wrong. Also the more expensive Ultrasonic sensors have resolutions down to the millimeter which is perfect, the HC-SR04 resolution is in centimeters.
To power the device, I decided to use a USB battery pack. That way the device can stay inside the mailbox and I can charge the battery pack as needed.
The Arduino's 5v and GND pins are connect to the screw terminals to power the board. The LED, HC-SR04, and Xbee Adapter's power and grounds are connected respectively to the breadboard.
The HC-SR04 Echo and Trigger pins are connected to pins 12 and 13 on the Arduino. The USB Xbee Adapter DIN and DOUT (pins 2 and 3) are connected to Arduino's RX and TX pins.
The Post Office
The Raspberry Pi Zero W is the intermediate device that connects the Arduino to MQTT Broker and the RESTFUL API hosted by Heroku. The Raspberry Pi (Central) attempts to connect to the Arudino 101 (Peripheral) through Bluetooth Low Energy (BLE). Once connected the Central waits until a value is updated from the Peripheral. When it receives the update it publishes the value to the MQTT Broker and terminates the application. The forceful termination is done to allow other devices to connect to the Arduino to check the status. Since the code is terminate, I have created it as a service on the Raspberry Pi. This allows the underlying operating system to restart the application and repeat the process mention above.
For more information on BLE and MQTT check out the links below.
MQTT - http://mqtt.org/faq
The Distribution Center
A RESTFUL API written in Node.js is hosted on Heroku to assist in communicating to Alexa. I also added a couple of addons to support some additional functionality like email notifications, as well as storing user information and preferences.
When I clean up the code a little I will post the api route that orchestrates the Alexa flow to all of the devices and software.