Unlocking Doors with Facial Recognition and a Mobile App - Hackster.io

2022-08-13 11:55:04 By : Mr. Michael Fu

Please ensure that JavaScript is enabled in your browser to view this page.

Almost every single building is accessible via a door, with many of them utilizing physical keys, NFC keycards, or simply waiting for the person inside to unlock it. So for Dillon McCardell's senior project, he created the AuraLock, which aims to use a person's face as they key and automatically unlock. This greater ease of access would also be paired with a highly capable mobile app that can remotely interact with the device for viewing past visitors or to simply provide an override to the locking mechanism.

The AuraLock is based around a Raspberry Pi 4, which acts as the controller between the mobile app and the physical hardware. A 12MP camera sensor provides the images to the Pi over its CSI connector ribbon. The deadbolt is moved with a 360-degree feedback servo whose resistance is read with an MCP3008 analog-to-digital conversion IC that helps stop it at the right time. Lastly, a magnetic door sensor helps detect when the door is open or closed in order to prevent the lock from activating at the wrong time, and a green LED indicates the lock's current status.

McCardell designed a custom PCB upon which the ADC chip was added and routed to pins below. After milling the circuit out of a copper-clad board, he then moved onto the next step of fabricating an enclosure for his project. The housing itself was 3D printed, whereas the lock mechanism, consisting of two gears and a toothed rack, were made from aluminum.

The AuraLock uses Google's Firebase service to communicate with the outside world and maintain a known, good state. This simple web API provides variables for everything the lock might need, including if a new face is being added, the state of the lock, if there is a delay present, and much more. These values can be set or read by either the Raspberry Pi or a mobile device with WiFi, thus allowing for remote communication over the internet.

Running on the Raspberry Pi 4 is a program with five main logical "threads" that each perform an independent task. The most important of these is the facial recognition/capture thread that takes an image periodically, processes it with OpenCV to determine a match with an approved face, sending the resulting image to Firebase along with setting the unlock state to True. Other threads monitor the if the door is open, set new approved faces internally, or even perform a remote lock/unlock if a request is set in Firebase.

Tying everything together is the AuraLock mobile app. Similar to the Raspberry Pi 4, it talks to the Firebase service in order to set or read values. But unlike the single board computer, it is also able to see captured images and even a history of who unlocked the door last.

With the hardware and software completed, McCardell built a small mock door and installed his locking device into its side. As the video on his blog post shows, it worked well at automatically recognizing the approved face, setting the "Unlock" variable to "True", and moving the deadbolt from the locked position. The code for the AuraLock project can be seen here on GitHub.