Arduino RFID 'Smart Door' Tutorial

Introduction: Arduino RFID 'Smart Door' Tutorial

By Peter Tran, 10ELT1

In this tutorial, you will work with an RFID reader module to unlock a micro-servo-powered door! Be sure you have the right access card to gain entry and not sound the alarm nor trigger the intruder lights.

You will be guided step by step and assisted with a 'Testing and Troubleshooting' guide and 'Real World Application' section at the end.

The code for this project is available at https://drive.google.com/drive/folders/1yVIvFhV17...

Please also download the necessary library for the RFID Sensor from https://github.com/AritroMukherjee/RFID

Supplies

  • Arduino UNO (or other compatible microcontroller)
  • Prototyping Breadboard
  • RFID Reader Module ((RFID-RC522) with RFID tags
  • Micro Servo (9g)
  • LEDs (Yellow, Green and Red)
  • Piezo Buzzers

Step 1: RFID Theory

What is an RFID reader?

Radio Frequency Identification (RFID) tagging is an ID system that uses small radio frequency identification devices for identification and tracking purposes. An RFID tagging system includes the tag itself, a read/write device, and a host system application for data collection, processing, and transmission. In simple words, RFID uses electromagnetic fields to transfer data over short distances.

RFID is useful to identify people, to make transactions, etc. You can use an RFID system to open a door. For example, only the person with the right information on his card is allowed to enter. In this tutorial, we have multiple RFID tags, each with its own Unique Identification (UID) but only one card will be granted access.

RFID-RC522 Pin Layout

Pin 1: VCC, positive power (3.3v)
Pin 2: RST, reset
Pin 3: Ground
Pin 4: IRQ, interrupt pin used to wake up module when a device comes into range
Pin 5: MISO, basically communications IN
Pin 6: MOSI. basically communications OUT
Pin 7: SCK, used as a clock/oscillator
Pin 8: SS, used as serial input

Step 2: Connecting the RFID Module

  1. Download the necessary library from the introduction section.
  2. Extract the contents from the zip folder "rfid-master" and add this library folder under the existing libraries of Arduino.
  3. Restart Arduino IDE
  4. The Arduino Code is linked at the start of the tutorial. Compile the code and eliminate any errors.
  5. Connect the Arduino UNO with the RFID reader. Refer to the pin wiring below, as well as the schematic diagram above for easy reference.

Pin Wiring from RFID-RC522 to Arduino Uno

SDA------------------------Digital 10
SCK------------------------Digital 13
MOSI----------------------Digital 11
MISO----------------------Digital 12
IRQ------------------------unconnected
GND-----------------------GND
RST------------------------Digital 9
3.3v-----------------------3.3v (DO NOT CONNECT TO 5v)

Step 3: ​Reading Data From RFID Tag

  1. Go to File > Examples > MFRC522 > DumpInfo and upload the code. This code will be available in Arduino IDE (after installing the RFID library).
  2. Open serial monitor and you should see something like the left figure above.
  3. Approximate the RFID tag to the reader.
  4. The information that can be read from the tag is listed in the right figure above. The yellow highlighted text is the RFID tag's Unique Identification (UID), note it down for later.

Attachments

Step 4: Testing the RFID Reader

  1. Insert the UID into the Arduino code where required (near the 'Authorised Access' section).
  2. Approximate the tag you’ve chosen to give access and you’ll see the authorised message.
  3. Approximate another tag with a different UID and you'll see the denial message.
  4. Refer to the 'Testing and Troubleshooting' section if you experience any issues.

Step 5: Micro Servo, LEDs and Buzzers

Micro Servo

  1. Connect a micro servo as per instructions on page 49-52 of the SparkFun SIK Guide (Version 3.2).
  2. The PWM pin of the servo should connect to pin6 on the Arduino.
  3. Refer to the reference code linked in the introduction titled "RFID_wITH_SERVO.ino" and the schematic above.
  4. Refer to the 'Testing and Troubleshooting' section if you experience any issues.

LEDs and Piezo Buzzers

  1. Install the LEDs and Piezo Buzzers with reference to the above diagram.
  2. Use the code "RFID_WithServo_and_Lights.ino"
  3. Refer to the 'Testing and Troubleshooting' section if you experience any issues.

Step 6: Testing and Troubleshooting

Testing

  1. The yellow LED should only be lit when no tag is being scanned.
  2. When an authorised RFID tag is used, the green light should flash twice with two beeps
  3. When a non-authorised RFID tag is used, the red light should flash three times with three beeps

Troubleshooting

  1. LED not lighting up: reverse the polarity of the LED by turning it around. The LED may have also blown.
  2. Program not uploading: Change the serial port in tools>serial port>
  3. Servo not twisting: Even coloured wires are shockingly easy to plug incorrectly.
  4. Servo still not working: don't forget to connect power (red and brown wires) to +5v and ground
  5. Servo just twitches: use an external power supply,

Step 7: Real World Application

RFID can be easily integrated into almost any security application, making this prototype very useful and appropriate for immediately real-world application. A similar model where an authorised RFID tag can activate a servo which unlatches a door can be used in:

  • office buildings
  • apartments
  • hotels
  • library seminar room check-ins
  • hire/rental cars

Some further advantages of RFID are:

  • Difficult to copy or hack. A radio signal can’t be “copied,” and the signal itself can be encrypted so other devices can’t decipher the data.
  • Customizable and programmable. An RFID key card can be programmed to open only specific doors (or only one) for a specific amount of time. (Hotels use keycards to authorize their guests only to access their hotel room and the fitness centre, set to stop working the morning of checkout.) This system allows management to restrict employee access only to specific authorized areas of the facility for certain amounts of time.
  • Anonymous. With no identifying marks on the key card, only the authorized user and the computer may know which door(s) the card will unlock.
  • Easily deactivated. If a keycard is lost or stolen, the system can easily deauthorize its identification signal — or the card may simply be allowed expire.
  • More cost-effective security. When physical keys are lost or compromised, the lock must be changed to restore security. When a key card is lost, it can be deauthorized, making it effectively disposable. No need to change the lock

Some disadvantages of RFID are:

  • RFID systems are often more expensive than barcode systems
  • RFID tags are usually larger than barcode labels
  • Tags are application-specific, no one tag fits all
  • Possibility of unauthorized reading of passports and credit cards
  • More than one tag can respond at the same time

Be the First to Share

    Recommendations

    • CNC and 3D Printing Contest

      CNC and 3D Printing Contest
    • Lamps Challenge

      Lamps Challenge
    • Rice & Grains Challenge

      Rice & Grains Challenge

    Comments