Introduction: Scure Lock With RFID Tag and PIN

You checked in a hotel and given a RFID tag to access your room. If you lost your card and someone else had the lost card can access to your room. Wouldn't it be more secure if another piece of information like PIN is required to open the door?

I have made a simple system using Arduino, RFID reader, display panel and keypad just to demonstrate that. Here I use a LED as a metaphor of a door lock.

Step 1: The Components

Follow are the list of hardware and software component required to build this project:

Arduino UNO & Genuino UNO



Generic Keypad

Jumper wires (generic)

Male/Female Jumper Wires

Arduino IDE

Some RFID/NFC cards

Step 2: Connect the LCD Display

Connect to LCD-LCM1602 IIC according to the following:

LCD GND pin to GND

LCD VCC pin to 5V

LCD SDA pin to analog 4

LCD SCL pin to analog 5

Please note that I am not able to find a 4-pin LCD-LCM1602 IIC item in fritzing, you need to match the above connection accordingly.

Step 3: Connect the LED

Connect the LED to pin 7.

Step 4: Connect the Keypad

Connect keypad according to the following configuration:

Keypad pin 1 to digital pin 5

Keypad pin 1 to digital pin 4

Keypad pin 1 to digital pin 3

Keypad pin 1 to digital pin 2

Keypad pin 1 to digital pin 14

Keypad pin 1 to digital pin 15

Keypad pin 1 to digital pin 16

Keypad pin 1 to digital pin 17

Please note that digital pins 14, 15, 16,and 17 are extended by analog pins A0, A1, A2, and A3.

Step 5: Connect the RFID Card Reader

I am using the RFID-RC522 card reader. Connect the card reader to match the following configuration:

RFID pin Reset to pin 9

RFID pin SS/SDA to pin 10

RFID pin MOSI to pin 11

RFID pin MISO to pin 12

RFID pin SCK to pin 13

RFID pin GND to pin GND

RFID pin 3.3V to pin 3.3V

Step 6: The Schema

This is the final schema.

Step 7: The Codes

Setup the cards, user names and passwords.

// init paralle arrays
byte knownCards[NR_KNOWN_CARDS][CARD_SIZE] = {
{0x93, 0x47, 0xe0, 0x00},
{0xe5, 0xa2, 0x9c, 0x2c}
char name[NR_KNOWN_CARDS][10] = {
char password[NR_KNOWN_CARDS][5] = {

Setup the keypad.

// define for keypad
#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 4;
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
byte rowPins[ROWS] = {5, 4, 3, 2};
byte colPins[COLS] = {14, 15, 16, 17};

Setup the LCD display.

// define for lcd
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address

The main event loop.

void loop() {

Step 8: Demo: a Welcome Prompt

A welcome greeting!

Step 9: Demo: Tag a RFID Card and Enter PIN

Tag a RFID card to the reader. You will see a greeting and be asked to key in a PIN. If you key in a wrong PIN or do not manage to key in a PIN within 30 seconds, it will show the welcome prompt again.

Step 10: Demo: Door Unlocked

If you key in a correct PIN, the red LED light will light up indicating that door is unlocked.

Automation Contest 2016

Participated in the
Automation Contest 2016

Internet of Things Contest 2016

Participated in the
Internet of Things Contest 2016

Sensors Contest 2016

Participated in the
Sensors Contest 2016