Project tutorial
Arduino RFID Keycard Access

Arduino RFID Keycard Access © Apache-2.0

Use the PN532 NFC available on the anduinoWiFi shield to create an RFID keycard building access system.

  • 1 comment
  • 27 respects

Components and supplies

Anduinowifi transbak jcmctckier
Andium Anduino WiFi
Ard due
Arduino Due
Ph abx00003 iso cxvgnsenmb
Arduino Zero
Adafruit RFID Card
NXP Micro NFC/RFID Transponder - NTAG203 13.56MHz

Apps and online services

About this project


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 Started

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.

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  


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  . 
   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. 
#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 Action

RFID KeyCard Access

It 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 
         //Serial.println("ACCESS GRANTED - Welcome New User"); 
         LCD.setTextColor(ST7735_WHITE); //white 
         LCD.screenPrint("Welcome New User", 0, 40); 
         //clear screen  
         //put back instructions 

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!


An Arduino library for the Andium(Anduino) shield. Transform your Arduino into an AndiumNode. Edit
Example sketch utilizing AnduinoNFC and AnduinoLCD library to create a simple RFID card access terminal. This sketch only prints information to the screen, but you could extend this to actuate a lock with a relay and the right locking mechanism! The sketch compares the UID of the scanned card to the pre programmed ID's defined at the top of the sketch.


Similar projects you might like

Security Access Using RFID Reader

by Aritro Mukherjee

  • 499 respects

NFC Color Changer

Project tutorial by Brian Carbonette

  • 3 respects

RFID Door Access Control with Counter

Project tutorial by sarful

  • 20 respects

IOT2020 - RFID Real-Time Access Control

Project tutorial by SIT

  • 37 respects

Access RFID with Light Feedback

Project showcase by Werzaire

  • 8 respects

Connecting Anduino to IFTTT

Project tutorial by Brian Carbonette

  • 15 respects
Add projectSign up / Login