Face-detecting door system triggered by doormat
-- Authored by Team "What the Hack" during H.A.R.D. Hack (Hackathon) at UC San Diego (with Wayne Li, Kamran Aladross, Daniel Truong, Ash Zafari and Thant Htoo Zaw), and won 3rd place.
Find us on Qualcomm's developer site!
(Trivia: Janus is the Roman god of doors, with two faces.)
The theme of this hackathon was "smart home". In lieu with the theme, we built a door that requires no keys, no pin codes, no magnetic strips, nothing physical - the user just needs a phone number with at least sms capabilities (preferrably mms too).
The unassuming welcome mat at the door is the next door bell. It is armed with a force resistor that has been tuned in Arduino so that a person of at least 25 kg/55 pounds equivalent to that of a kid will trigger the face-detecting camera. The user will not be aware of it, as the camera does the peeping for you and searches for faces. When it detects one, it sends the user a photo of the scene with the face highlighed and asks if the user wants to unlock the door for the guest. If the user texts
unlock, the door will unlock and let the guest in. It will lock back whenever the door is closed again due to the flex sensor installed at the hinge.
This project was built with backward compatibility as well as availability in mind as we move forward. Multiple phone numbers can be notified, and potentially issue the
unlock command too if you buy Twilio's non-trial phone number. Any phone with sms capability can send the 'unlock' code to unlock the door, so even my grandpa who still prefers feature phones is still in control. Control the door from your bed with Janus.
DragonBoard 410c with Power Supply
Arduino Uno with USB cable to power
web camera (USB)
wiring (breadboard & jumper wires)
microSD card (for setting up the OS of DragonBoard)
![Inside look at servo motor lock](http://i.imgur.com/JZBUXkd.jpg =10x10) ![DragonBoard behind the scene](http://i.imgur.com/dnaatbW.jpg =10x10) Software:PREVIEW
Refresh your repositories.
sudo apt-get update -y sudo apt-get upgrade -y
Download the repository as a zip and extract it. Go the extracted folder.
Download all the necessary software packages and libraries, including any text editor.
mkdir janus cd janus sudo apt-get vim sudo apt-get install python sudo apt-get install pyton-opencv sudo apt-get install pip sudo pip install twilio sudo pip install flask
Download ngrok. Unzip it using
Choose your port numbers and edit the file to initialize your gpio input and output ports. Run the script after editing.
vim initialize_gpio.sh ./initialize_gpio.sh
Register for a Twilio account, and set up a free phone number.
Change account_sid, auth_token, RECEIVING_PHONE and TWILIO_NUMBER in
send_sms.pyfile to match those in your Twilio account.
- Type the following line to activate
ngroktunneling at port
5000in a new terminal. Note down the web address ending in
.ioon the 5th line beside forwarding. Keep this window open.
xterm -e ./ngrok http 5000
respond_sms.pyscript that enable receving commands via sms. It will open up a new terminal. Keep it open.
xterm -e python respond_sms.py
- Change the permissions so that all scripts are enabled to read, write and execute.
- Enter email credentials and your phone number (near the end of the file) into the face detection script.
(Optional) Conceptually, this should be the end step. Activating the force sensor runs the detect_face.py script. However, we ran into OpenCV issues integrating the python script into bash script, or the python script into another python script with subprocess bash call. However, if you want to test out the force resistor (our door mat), run the script
xterm -e ./activate_janus.shand it will print in a new terminal the signal received from the force resistor through Arduino. If you want, you can try out the concept by deleting the '#' signs to uncomment the if conditional line in the shell script.
Manually start the face detection script.
python detect_face.py haarcascade_frontalface_alt2.xml
The camera will load up.
When it finds a face, it sends a multimedia message from your email to your phone, as well as a sms notifying the user that a guest is at the door and asking for a reply. Replying
unlockto the sms will unlock the door. It has to be opened within 3 seconds of unlocking. After opening the door, it will stay unlocked until it has been closed back, ensured by the flex sensor.
Congratulations! Janus now serves you.