Alexa Smart Mailbox
Build a smart mailbox that uses Arduino, Raspberry Pi, and Alexa to notify you when mail arrives.
- Arduino
- Advanced
- 150 minutes
- 6 steps
Shop this project
CartYou'll need
Arduino Uno Rev 3Board Only$32.24
Raspberry Pi 5 8GB Board Only$175.00
Male-Male Jumper Wires (Set of 65-assorted sized and colors)$6.99
Prices from vilros.com. Tax and shipping at checkout.
Before you start, you'll need
- Arduino Uno
- Raspberry Pi 3 Model B
- Proximity sensor (IR or ultrasonic)
- USB microphone
- External speaker (3.5mm)
- Jumper wires
Program Arduino mail sensor
About 20 minutes
Detect mail with proximity sensor.
- Connect proximity sensor to Arduino Pin 5.
- Connect sensor VCC to 5V, GND to GND.
- Upload Arduino sketch to read sensor.
- Arduino sends '1' via serial when mail detected, '0' otherwise.
int sensor = 5;
int mail = 0;
void setup() {
pinMode(sensor, INPUT);
Serial.begin(9600);
}
void loop() {
mail = digitalRead(sensor);
if (mail == 1) {
Serial.write(1);
} else {
Serial.write(0);
}
delay(1000);
}Sensor detects mail presence in mailbox.
You should see
Arduino detects mail and sends serial signal.
Install Raspberry Pi software
About 30 minutes
Set up Flask and Alexa integration.
- On Raspberry Pi, update system: sudo apt-get update && sudo apt-get upgrade
- Install dependencies: sudo apt-get install python2.7-dev python-pip python-serial
- Install Flask: sudo pip install Flask flask-ask
- Connect Arduino to Pi via USB.
You should see
Required libraries are installed.
Write the Alexa skill backend
About 30 minutes
Create Python server to communicate with Alexa.
- Create a Python script on Raspberry Pi.
- The script reads Arduino serial data.
- Flask-ask creates endpoints for Alexa skill.
from flask import Flask
from flask_ask import Ask, statement
import serial
ser = serial.Serial("/dev/ttyACM0", 9600)
app = Flask(__name__)
ask = Ask(app, '/')
@ask.launch
@ask.intent("Check")
def check_mail():
mail_present = ser.read()
if mail_present == 1:
return statement("New mail has arrived. Check it soon!")
else:
return statement("No mail yet.")
if __name__ == "__main__":
app.run(debug=True)Adjust serial port if not /dev/ttyACM0.
You should see
Flask app runs without errors.
Create HTTPS endpoint with ngrok
About 15 minutes
Expose Flask server to internet.
- Download ngrok from ngrok.com.
- Run: ./ngrok http 5000
- Copy the HTTPS URL (e.g., https://abc123.ngrok.io).
- This URL will be used for Alexa skill configuration.
You should see
Ngrok provides an HTTPS endpoint.
Configure Alexa skill
About 40 minutes
Set up Alexa Developer Console skill.
- Log in to developer.amazon.com/alexa.
- Create new skill: Name='MailBoxChecker', Invocation='mailbox checker'.
- Add intent: 'Check' with sample utterance 'check the mailbox'.
- Set endpoint to ngrok HTTPS URL.
- Choose SSL certificate type: 'wildcard subdomain'.
- Save and build the model.
- Enable skill for testing.
You should see
Alexa skill is created and enabled.
Test with Alexa
About 15 minutes
Ask Alexa about your mail.
- Make sure Flask app is running on Pi.
- Make sure ngrok tunnel is active.
- Say: 'Alexa, ask mailbox checker to check the mailbox'.
- Alexa should respond with mail status.
- Place mail in mailbox to trigger sensor.
- Ask Alexa again—she should confirm new mail.
You should see
Alexa accurately reports mail status.
It didn't work
Alexa can't connect to skill.
Verify ngrok URL is correct in Alexa skill endpoint. Ensure Flask app is running. Check firewall settings on Pi.
What to do next
Stuck? Contact Vilros Support with your board model and what you see on screen.