Use the PN532 NFC available on the anduinoWiFi shield to create an RFID keycard building access system.
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.
To 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.
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
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 Rights
At 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. */
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:
Read more: Arduino RFID Keycard Access