NameNetIDSection
Elliot Rubinearubin2ECE 120
Henry Borsukhborsu2ECE 110
Neal Specterdelta2ECE 110
Esther Changeachang2ECE 120

Introduction


Statement of Purpose

Our goal was to create an RFID door lock, or an electronic lock that can only be opened by a key with the radio frequency the same as the lock. Our goal in building this lock was inspired by the ongoing pandemic, where everyone is scared of handling anything foreign. Thus, by designing and creating this contactless lock, we aim to reduce the spread of COVID-19 and disease in general. The lock can also be an effective safety measure, since it reduces the chance of unauthorized entry to a person's home significantly. 

Features and Benefits


List and provide description of the features and benefits of your project. 


Design

System Overview


NameFunction
HID RFID ReaderRFID reader that reads 125Khz cards and then sends the data to the microcontroller
MicrocontrollerControls everything, determines if the card is valid or not, and then determines whether to lock or unlock the door as a result.
PowerPower for the whole system.
Valid Card LEDIf the door is unlocked, the light will be green, otherwise it will be red
MotorLocks and Unlocks the door
Lock DoorIf the door is currently unlocked and the "Lock Door Button" is pressed, the door will lock.
Unlock DoorIf the door is currently locked and the "Unlock Door Button" is pressed, the door will unlock.
ANDAnd gate
Door LockedSignal of whether the door is locked.
Door UnlockedSignal of whether door is unlocked.
Lock ButtonUser input to lock the door.
Unlock ButtonUser input to unlock the door.

Design Details



Design Details



This is a picture of the Step Motor Driver design connected to a tiny stepper. It closely follows the circuit schematic shown in Appendix 1.2 [2]. However, we used a different stepper 
Design Modifications: 
A design that we modified was the RFID Antenna, which we replaced with a pre-built RFID reader. We also chose to create a software FSM that locks and unlocks the device instead of creating a programming mode. Lastly, instead of using the NodeMCU, we used the Arduino MKR1000 WiFi board. 

Results

  1. Results

    As is shown in our video, we were able to create a functional RFID door lock using the integrated RFID sensor. Upon presentation of a valid card, the sensor beeps, changes the LED color, and activates the stepper motor. The two buttons on the breadboard, lock and unlock, allow the user to change the state of the lock without entering the device's firmware. This software functionality is shown in Appendix 1.1, while the hardware implementation can be found in the Schematic section

  2. Problems and Challenges

    We ran into a lot of trouble when tuning the antenna. Therefore, we ended up not using the RFID IC and antenna network that we originally designed since it was delaying progress with other components of our project. Specifically, we could not achieve the correct antenna impedance specified by the datasheet, so no 125kHz tag would be able to resonate with the circuit properly. Our original microcontroller, the NodeMCU ESP2866 board, did not end up working either. While our code did compile, it would not upload to the board so we could not use it. Instead, we used a MKR1000 Arduino WiFi board which worked much better, and also had a +5V output which eliminated some clutter on the breadboard. Similarly, because our RLC circuit did not work out, we just used an HID Prox Pro II RFID sensor which eliminated our antenna tuning problems. Finally, perhaps the biggest challenge we encountered was that half of our group is off-campus this semester. This made it hard for everyone to contribute in the ways that they may have hoped to.

  3. Future Plans

    If possible, we hope to resolve the antenna tuning issues that we encountered during this project. We understand the action behind the RFID IC and the oscillator circuit itself, it is just very difficult to get accurate measurements of things like antenna current, impedance, and frequency without more experience and equipment. It seems that, since the impedance of an inductor varies with angular frequency, we may not have had the correct angular frequency to begin with. This is something that our equipment would have trouble detecting, and is also a subtlety that we did not have the time or experience to address. Clearly, antenna tuning is the next and most critical element of the project, and something we must account for when planning out the design and building process. We also would like to use EEPROM to store valid RFID card addresses. As the Arduino's EEPROM is insufficient for doing this, we would need an alternative memory chip.

Appendix:

Arduino Code (1.1)

Arduino RFID Door Lock Code
#include <Stepper.h>
#include <Arduino.h>
#include "HidProxWeigand.h"
 
#define RDR_INT0 1         // Reader interrupt for DATA 0.
#define RDR_INT1 0         // Reader interrupt for DATA 1.
 
#define PIN_DATA0 0        // The pin to use for DATA 0.
#define PIN_DATA1 1        // The pin to use for DATA 1.
 
 
/* 
 * Written by: Henry Borsuk
 * 
 * Code based off of example code from GitHub user "cyrusbuilt"
 * The following project is designed to be used with the Arduino MKR-1000.
 * 
 * PINS
 * FOLLOWING PINS ARE FOR ARDUINO-MKR1000
 * Item             Pin Number
 * Buzzer           5
 * RFID DATA0       0       
 * RFID DATA1       1
 * Servo            8,9,10,11
 * LED GREEN        4
 * Lock Button      3
 * Unlock Button    2
 * Locked Signal    6
 * Unlocked Signal  7
 *
 */
 
int approvedCards[3] = {81558,81722,55988}; // Array of approved cards
bool doorLocked = false; //Global status variable
bool spinMotorToLock = false; 
 
 
//Declaring pin variables
const int buzzer = 5;
const int greenLED = 4;
const int unlockButton = 2;
const int lockButton = 3;
const int lockedSignal = 7;
const int unlockedSignal = 6;
const int stepsPerRev = 200;
 
ProxReaderInfo* reader1;   // Card reader 1.
Stepper lockMotor(stepsPerRev, 8, 9, 10, 11);
 
// Function for handling card reads.
void cardReadHandler(ProxReaderInfo* reader) {
    Serial.print(F("Card read: "));
    Serial.print(reader->facilityCode);
    Serial.print(F(":"));
    Serial.println(reader->cardCode);
    int cardRead = reader->cardCode;
     
     
    if(reader->cardCode == 81722 || reader->cardCode == 81558 || reader->cardCode == 55988){
      Serial.println("VALID CARD");
      if(doorLocked == true){
        unlockDoor();
      }
      else if(doorLocked == false){
        lockDoor();
      }
    }
    else {
      Serial.println("INVALID CARD");
    }
}
 
// Handle interrupt for DATA 0.
void handleInterrupt0() {
    if (reader1 != NULL) {
        reader1->ISR_Data0();
    }
}
 
// Handle interrupt for DATA 1.
void handleInterrupt1() {
    if (reader1 != NULL) {
        reader1->ISR_Data1();
    }
}
//Function that unlocks the door
void unlockDoor(){
  lockMotor.setSpeed(180);
  lockMotor.step(-100);
  delay(500);
  digitalWrite(greenLED, LOW);
  digitalWrite(buzzer,LOW);
  delay(500);
  digitalWrite(buzzer,HIGH);
  Serial.println("Door Unlocked");
  //digitalWrite(greenLED, HIGH);
  doorLocked = false;
  digitalWrite(unlockedSignal, HIGH);
  digitalWrite(lockedSignal, LOW);
}
//Function that locks the door
void lockDoor(){
  lockMotor.setSpeed(180);
  lockMotor.step(100);
  delay(500);
  digitalWrite(greenLED, LOW);
  digitalWrite(buzzer,LOW);
  delay(200);
  digitalWrite(greenLED,HIGH);
  digitalWrite(buzzer,HIGH);
  delay(200);
  digitalWrite(greenLED, LOW);
  digitalWrite(buzzer,LOW);
  delay(200);
  digitalWrite(greenLED,HIGH);
  digitalWrite(buzzer,HIGH);
  Serial.println("Door Locked");
  doorLocked = true;
  digitalWrite(lockedSignal, HIGH);
  digitalWrite(unlockedSignal,LOW);
}
 
//Deprecated function
boolean checkValid(int card)
{
  for(int i = 0; i < 3; i++)
  {
    Serial.print("Card Read: "); Serial.println(card);
    Serial.print("Approved Card "); Serial.print(i); Serial.print(" "); Serial.println(approvedCards[i]); 
    if(card == approvedCards[i])
    {
      return true;
    }
    else
    {
      return false;
    }
  }
}
//Code that is run initially at startup
void setup() {
    Serial.begin(9600);
    //Setting up all GPIO pins
    pinMode(buzzer, OUTPUT);
    digitalWrite(buzzer,HIGH);
     
    pinMode(greenLED, OUTPUT);
    digitalWrite(greenLED, HIGH);
 
    pinMode(lockButton, INPUT);
    pinMode(unlockButton, INPUT);
    pinMode(lockedSignal, OUTPUT);
    pinMode(unlockedSignal, OUTPUT);
    digitalWrite(lockedSignal, LOW);
    digitalWrite(unlockedSignal,HIGH);
    lockMotor.setSpeed(180);
    //delay(500);
    lockMotor.step(100);
    while (!Serial) {
        delay(10);
    }
    // Create the reader and attach it to the system.
    reader1 = HidProxWeigand.addReader(PIN_DATA0, PIN_DATA1, cardReadHandler);
 
    // Attach interrupt handlers for reader.
    HidProxWeigand_AttachReaderInterrupts(RDR_INT0, RDR_INT1, handleInterrupt0, handleInterrupt1);
}
 
void loop() {
    // Process any cards that have been read.
    HidProxWeigand.loop();
    if(digitalRead(lockButton) == HIGH){ //Checks buttons to unlock or lock door from inside
      lockDoor();
    }
    if(digitalRead(unlockButton) == HIGH){
      unlockDoor();
    }
    if(spinMotorToLock){
      lockMotor.step(200);
      delay(500);
      spinMotorToLock = false;
    }
}

References (1.2)

[1]P. Bevelacqua, "Impedance of an Antenna", Antenna-theory.com, 2021. [Online]. Available: https://www.antenna-theory.com/basics/impedance.php. [Accessed: 10- May- 2021]

[2]"Lab: Controlling a Stepper Motor With an H-Bridge – ITP Physical Computing", Itp.nyu.edu, 2021. [Online]. Available: https://itp.nyu.edu/physcomp/labs/motors-and-transistors/lab-controlling-a-stepper-motor-with-an-h-bridge/. [Accessed: 10- May- 2021]

[3]"SN745510NE", Ti.com, 2021. [Online]. Available: https://www.ti.com/lit/ds/symlink/sn754410.pdf. [Accessed: 10- May- 2021]

[4]"125kHz RFID transceiver", Melexis, 2021. [Online]. Available: https://www.melexis.com/en/product/MLX90109/125kHz-RFID-Transceiver. [Accessed: 10- May- 2021]

[5]"cyrusbuilt/HidProxWeigand", GitHub, 2021. [Online]. Available: https://github.com/cyrusbuilt/HidProxWeigand. [Accessed: 10- May- 2021]