Keys are so last century, and now that you can easily replicate a physical key just by snagging a photo it might be time to upgrade our locks! This project outlines a framework for you to get started implementing your own unique locking mechanisms.
In this project you'll authenticate individuals using Mifare Classic RFID Tag UIDs and display a message on the LCD screen. Once you get this working we're curious to see where you take it next. We're thinking about maybe logging access stats to a google sheet, customizing the lighting in the room based off who just entered, or even 2 factor authentication door locks using a service like twilio! Imagine having to respond to a text from your car before you could get in? Let's dive in!
***Disclaimer*** Don't lock up anything too precious with UIDs only! Mifare Classic ISO 14443A with 4 byte UIDs are totally not that secure. You can brute force guess the UID, buy RFID tags and customize the UIDs prior to shipping, intercept the unencrypted transmission, etc... UID duplicates undoubtedly exist in the wild as well as there are no strict standards for "uniqueness". You can combine these with other forms of authentication or create you're own schema utilizing more data than just the UID to create more secure systems.
Getting StartedTo start with this demo you'll need an Arduino Zero or Due paired with an anduinoWiFi shield, and some RFID tags. We chose to use these Mifare Classic RFID keycards although any ISO 14443-A NTAG-203 compatible tags will work!
If you haven't yet used NFC on the anduinoWiFi swing by our getting started guide to make sure everything is setup and working properly. Much like we do in the guide, let's run the File>>examples>>AnduinoNFC>>readRFIDTag to grab our tags UIDs.
Read some RFID tags!Run the sketch, scan a tag, and the output in the serial terminal should look something like:
Tag is not NDEF formatted.
NFC Tag - Mifare Classic
UID BA 61 20 00
or
NFC Tag - Mifare Classic
UID 11 6F 8D FC
NDEF Message 1 record, 43 bytes
NDEF Record
TNF 0x1 Well Known
Type Length 0x1 1
Payload Length 0x27 39
Type 55 U
Payload 00 68 74 74 70 73 3A 2F 2F 67 69 74 68 75 62 2E 63 6F 6D 2F 61 6E 64 69 75 6D 2F 41 6E 64 75 69 6E 6F 2F 77 69 6B 69 .https://github.com/andium/Anduino/wiki
Record is 43 bytes
Depending on whether you've NDEF formatted the cards. (We get more into NDEF in the nfcColorSelect demo, this tag happens to encoded with an url).Jot down your unique UIDs and save them for later. Its time to set up our keycardAccess sketch!
Navigate to File>>examples>>AnduinoNFC>>keycardAccess and lets start making some changes!
Configure Access RightsAt the top of the sketch you should see some #define statements.
/* Replace these UIDs with the UIDs on your RFID tags. If
* you're unsure what they are run the readRFIDtag sketch
* and check the tag info that's printed to the terminal.
* Depending on the card type the length will will vary.
*/
#define BRIAN_ID "BA 61 20 00" //UID from Mifare KeyCard
#define DOOLEY_ID "12 AA 1A 00" //UID from Mifare KeyCard
Feel free to change the names and be sure to edit the UIDs to match the UIDs of the cards you'd like to grant access. If the UID doesn't match either of these it will be denied access. For our demo we're using:
- INTRUDER!: UID 11 6F 8D FC
- Dooley: UID 12 AA 1A 00
- Brian: UID BA 61 20 00
That's it! Make these changes, flash the sketch, and scan some tags! Let's check our output.
RFID Access In ActionIt works! Want to add more users? Here's how we're checking UID and displaying the name:
if(UID == NEW_USER_ID)
{
//Open the lock!
//Turn on the lights? Fire a siren? Log the Access?
//clear screen
clearScreen();
//Serial.println("ACCESS GRANTED - Welcome New User");
LCD.setTextSize(2);
LCD.setTextColor(ST7735_WHITE); //white
LCD.setTextWrap(true);
LCD.screenPrint("Welcome New User", 0, 40);
delay(2000);
//clear screen
clearScreen();
delay(500);
//put back instructions
scanInst();
}
Just edit this chunk and add it as an 'else if' to the sketch. Don't forget to add a #define for the new UID at the top of the sketch as well.
#define BRIAN_ID "BA 61 20 00" //UID from Mifare KeyCard
#define DOOLEY_ID "12 AA 1A 00" //UID from Mifare KeyCard
#define NEW_USER_ID "00 02 20 A4" //new UID
What's next?Now that you've got this much working you're ready to expand keycardAccess into a unique new internet connected access control system, and good news, the WiFi shield is already connected!
Comments