- 1 Proposal
- 2 Design and Solutions
- 3 Results
This is a NFC-enabled smart lock that interfaces with existing standard deadbolt assemblies. It allows a user to unlock their door(s) with their smartphone or an NFC tag without needing to carry around annoying physical keys.
The team of two will design and assemble an electronic, Arduino-powered drop-in deadbolt assembly that can be unlocked with registered NFC-enabled devices such as the Apple Watch, newer iPhones, or most Android phones. The lock will be operated by a Particle Photon chip; the Photon is be web-enabled and will be NFC-enabled thanks to a PN532 NFC breakout board, allowing it to check NFC credentials and be operated remotely from a web app or mobile app. A small battery pack (x6 AA's) will provide power to the Arduino and servo.
A detailed user story indicating the flow of events that allow the lock to function:
- John Doe downloads the native iOS app for the smart lock
- John Doe signs in to his Lock account on the native app, linking his phone's credentials to his account
- John approaches the door with the phone, and the phone recognizes the NFC signal coming from the Photon
- The phone sends an encrypted HTTPS web request to the Photon's webhook API along with its unique credentials (UID or Serial No.)
- The Photon accepts the request, checks the data against its list of registered devices, and decides whether or not to open the deadbolt
- If the credentials are approved, the Photon will apply an electronic signal to the deadbolt servo, opening the door
- Kai Banks
- Nikki Wines
- Nathan Schmetter (TA)
- James Feher (Instructor)
- Use NFC-enabled device to unlock your deadbolt (assuming the device is registered & authorized)
- Secure, relatively hack-proof system
- Polished finished product (custom-designed 3d-printed enclosure, etc.)
- Web-enable product so that it can be monitored & manipulated from web app and native iOS app
- Replace AA battery pack with rechargeable pack for convenience
- Implement backup authentication method in case wifi or power goes out
The NFC Lock will be compatible with any door with a standard lock hole. The outward-facing side will consist of a standard doorknob and small NFC-enabled area. The inward-facing side will feature a standard doorknob and will house the Arduino and power supply (or will connect to a wall outlet for prototyping purposes, if power turns out to be an issue). The inward-facing side, which will look like a plastic block several inches in height and width, will also house the servo motor that attaches to and manipulates the deadbolt.
Technology-wise: the Arduino will constantly emit a low-power NFC signal from the outside of the door. When a phone comes into proximity with the signal, the native NFC Lock app will be launched automatically (or manually, if this proves difficult) and will submit a webhook request to the Particle API. This encrypted request will contain the phone's unique information. The Photon will interpret the request and check the enclosed credentials against an encrypted list of authorized credentials. If the credentials are not found in the list, the door will not open; if they are, the Arduino board will send power to the servo, opening the deadbolt for ten-ish seconds and allowing the authorized user in.
- First and foremost, security. All web requests MUST be encrypted & sent through HTTPS (as they may contain sensitive information, like phone UIDs and serials)
- Not biting off more than we can chew (see Goals section)
- Keeping budget under $150 for a pretty high-tech product
- Not using an unnecessarily large amount of battery during normal operation (minor)
- Particle Photon (Arduino Uno with a Particle shield) - [link] - have (normally $20)
- Deadbolt, knobs, assembly - have (not included in price because product relies on there already being a deadbolt present)
- 3D-Printed Enclosure - free
- Servo Motor to control Deadbolt - [link] - $18
- NFC Reader - [link] - $40
- Demo door assembly - $15
Design and Solutions
Module 1: Particle Photon + NFC Board
The first objective of the project was to get the Particle Photon microcontroller talking to the PN532 NFC breakout board. The idea was to get the NFC board to recognize the presence of NFC tags and then send the information encoded within the tags to the Photon, which would determine what corresponding action to take. For an in-depth tutorial on how we achieved this goal, check this link. The basics are as follows:
- solder header pins onto the PN532 board
- set up included jumpers on the board to use hardware SPI mode
- wire the board to a 4050 level shifter chip according to online schematics
- wire the 4050 to the Photon's pins according to those schematics
- load the PN532 Arduino library onto the Photon
- start up the PN532 from the Photon in code
These steps allowed us to check for the presence of NFC tags with the PN532 board, send a tag's information back to the Photon, and deal with the information appropriately within the Photon's code. Code here.
Module 2: Photon + I/O
The I/O for this project involved three components:
- PN532 Board (see above)
- Inner Button: we needed a way to interact with the Photon from the inside, seeing as the knob part of the deadlock would be covered by the 3D-printed enclosure. As a result, we chose to wire a simple pulldown button that would lock and unlock the door from the inside.
- Deadbolt Servo: the Photon needed to somehow manipulate the deadbolt. We chose this high-torque hobby servo. Initially, we were concerned that the Photon wouldn't be able to output enough voltage to power the servo, but wiring the servo directly to the VIN pin allowed us to get close to the suggested 5 volts and it worked great without a voltage converter.
This module was the simplest, but was a critical component of the overall assembly. We had several issues with servos (one burnt out, and another disappeared) so this module held us back for longer than we would have liked.
Module 3: Native iOS App
Module 4: Housing + Demo Setup
At this point, everything was working great - the servo actuated properly when an authorized NFC card was brought into proximity with the reader, the button functioned nicely, and the iOS app could control the servo from afar through the Particle API - but it had no housing/enclosure. After many hours in the CAD lab on campus, we stumbled across a Thingiverse page that was designed for a very similar smart lock application. We edited the STL files to fit our own servo and wires, printed it out, and everything fit perfectly.
Once the enclosure was finished and the wiring was set, we needed to attach the assembly to a "demo door". We used a 1.75"-thick door for the demo. We drilled appropriately-sized holes for standard deadbolts, purchased a standard Kwiset deadbolt from Home Depot, and attached everything to the door.
One of the most difficult parts of the entire project was getting the NFC breakout board to communicate properly with the Particle Photon. We created an in-depth tutorial (linked below) that illustrates exactly how to get the two devices working in tandem.
Comparison to Original Objectives
Though the project overall was a success, we were unable to implement one of the features we wanted to from the start: allowing an iPhone's NFC capabilities to talk to the PN532 chip. We spent hours and hours trying to get this to work, to no avail, until extensive research finally revealed that native iPhone apps will not talk to NFC boards unless those boards have a Secure Element installed. According to securetechalliance.org: "The secure element (secure memory and execution environment) is a dynamic environment in which application code and application data can be securely stored and administered and in which secure execution of applications occur. The element resides in highly secure crypto chips (usually a smart card chip)." Such a chip, and its corresponding software license, costs several hundred dollars and was not within the scope of this project.
Essentially, iPhones will not communicate with non-secured NFC chips to avoid situations in which a NFC reader may be programmed to steal data from the iPhone. As a result, we chose to have our native app interact with the Photon via the Particle API (which is fully encrypted and very secure) instead, and we used a NFC tag (in the form of a card) instead of a smartphone's NFC capabilities.
Outside of that, our project was successful in every way. The deadbolt opened when approached by an authorized NFC card, the iOS app interfaced nicely with the Particle API, and the enclosure did a great job of hiding some of the messiness and holding the servo tightly against the deadbolt.