Design An RFID-Based Access Control with Disinfectant Booth

RFID-based access control with a disinfectant booth is a security system that uses radio frequency identification (RFID) technology to control access to a building or room, while also disinfecting people who enter. RFID tags are small, electronic devices that can be attached to people’s clothing or carried on their person. When an RFID tag passes through an RFID reader, the reader can identify the tag and the person carrying it.

In this project design, RFID-Based Access Control with Disinfectant Booth, we design and construct model of an RFID based access control booth that can be placed at the entrance of a door. It will give only people with the permitted RFID card access to pass and once these people enter the model booth, it will activate the spraying of a disinfectant fog that will sanitize the people. For example, this RFID-based access control system could be used to track employee attendance or to track patients in a hospital.

900W Fogging Heater
900W Fogging Heater

A disinfectant booth is a device that sprays people with disinfectant as they pass through it. This can help to prevent the spread of diseases such as COVID-19. An RFID-based access control system with a disinfectant booth can be used to ensure that only authorized people enter a building or room, and that those people are disinfected before they enter. This can help to improve security and reduce the risk of spreading diseases.

Here are some of the benefits of using an RFID-based access control system with a disinfectant booth

  • Improved security: RFID-based access control systems can help to improve security by preventing unauthorized people from entering a building or room.
  • Reduced risk of spreading diseases: Disinfectant booths can help to reduce the risk of spreading diseases by spraying people with disinfectant as they pass through.
  • Increased efficiency: RFID-based access control systems can help to increase efficiency by automating the process of granting access to people.
  • Improved data collection: RFID-based access control systems can be used to collect data about people’s movements and activities. This data can be used to improve security, efficiency, and decision-making.

How to Design An RFID-Based Access Control with Disinfectant Booth

The Components Needed

ComponentsQuantity
Cubicle booth of suitable size1
L298N Module1
stepper motor1
Double Channel Relay module1
12V DC Power Supply1
220V AC pump1
900W Fogging Heater1
Threaded 40cm Rod1
RFID module MFRC5221
Arduino Mega Dev Board1
1602 LCD module1
RFID tags or Debit Cards4
3×6 inch box1
LCD connector Wire1
miscellaneous6

Read

RFID-Based Access Control With Disinfectant Booth: The Schematic Diagram

Explanation of Circuit Diagram

The circuit diagram shown above used the Arduino Mega board as the brain of the project design. The Arduino mega board controls the 2 channel relays from an IO pin. One of the relays is needed to pump disinfectant liquid when the fog heater is hot enough the other is needed to control the fog heater from excess heat and damage. The Fog heater comes with a thermostat that we can use to cut off AC voltage supply to the fog heater when it is hot enough.

The thread rolling machine and fog machine
The thread rolling machine and fog machine

We used the L298N motor driver module that is made up A4988 IC to control the stepper motor to slide the door forward to ensure closing of the booth model door and backwards to simulate opening of the door. This action would be made possible by the thread roll machine system that is being controlled by the stepper motor.

The Arduino Sketch for The Project Design

#include <Arduino.h>
#include "BasicStepperDriver.h"
#include <EEPROM.h>     // We are going to read and write PICC's UIDs from/to EEPROM
#include <SPI.h>        // RC522 Module uses SPI protocol
#include <MFRC522.h>  // Library for Mifare RC522 Devices
#include "max6675.h"
//#include <Servo.h>
#include <LiquidCrystal.h> //include the LCD lib
//declear what LCD pins u are sending data
const int rs = 15, en = 14, d4 = 13, d5 = 12, d6 = 11, d7 = 10;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

// Motor steps per revolution. Most steppers are 200 steps or 1.8 degrees/step
#define MOTOR_STEPS 200
#define RPM 260

// Since microstepping is set externally, make sure this matches the selected mode
// If it doesn't, the motor will move at a different RPM than chosen
// 1=full step, 2=half step etc.
#define MICROSTEPS 1

// All the wires needed for full functionality
#define entry_DIR 2
#define entry_STEP 3
#define entry_open 4
#define entry_close 5
#define exit_DIR 6
#define exit_STEP 7
#define exit_open 8
#define exit_close 9
int thermoDO = 32;
int thermoCS = 33;
int thermoCLK = 34;
//define the temp boundries
float lowerBoundry = 160.00;
float higherBoundry = 200.00;
//define relays
const int pump_relay = 30;
const int element_relay = 31;
//define motion sensor pin
const int motion_pin = 48;
//define lcd backlight pin
const int lcd_pin = 47;

//define some variables to store data used in the program
float temp;
int On = LOW; // Active Low relay used, LOW will mean ON.
int Off = HIGH; // Active low relay used.

// Create MFRC522 instance.
#define SS_PIN 53 
#define RST_PIN 49
MFRC522 mfrc522(SS_PIN, RST_PIN);


MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);

bool programMode = false;  // initialize programming mode to false
uint8_t successRead;    // Variable integer to keep if we have Successful Read from Reader
byte storedCard[4];   // Stores an ID read from EEPROM
byte readCard[4];   // Stores scanned ID read from RFID Module
byte masterCard[4];   // Stores master card's ID read from EEPROM

// 2-wire basic config, microstepping is hardwired on the driver
BasicStepperDriver entry_door(MOTOR_STEPS, entry_DIR, entry_STEP);
BasicStepperDriver exit_door(MOTOR_STEPS, exit_DIR, exit_STEP);

bool motion(){
  if(digitalRead(motion_pin) == HIGH){
    return true;
  }

  else{return false;}
}

void lcd_light(int state){
  digitalWrite(lcd_pin, state);
}

bool open_entry(){
  while(1){
    entry_door.rotate(360);
    Serial.println("Opening Entry Door..");
    lcd.setCursor(0, 1);
    lcd.print("Opening Entry....");
    if(digitalRead(entry_open) == LOW){
      entry_door.stop();
      Serial.println("Door Stopped");
      return true;
    }    
  }
}

bool open_exit(){
  while(1){
    exit_door.rotate(360);
    Serial.println("Opening Exit Door..");
    lcd.setCursor(0, 1);
    lcd.print("Opening Exit....");
    if(digitalRead(exit_open) == LOW){
      exit_door.stop();
      Serial.println("Door Stopped");
      return true;
    }    
  }
}

bool close_entry(){
  while(1){
    entry_door.rotate(-360);
    Serial.println("Closing Entry Door..");
    lcd.setCursor(0, 1);
    lcd.print("Closing Entry...");
    if(digitalRead(entry_close) == LOW){
      entry_door.stop();
      Serial.println("Door Stopped");
      return true;
    }    
  }
}

bool close_exit(){
  while(1){
    exit_door.rotate(-360);
    Serial.println("Closing Exit Door..");
    lcd.setCursor(0, 1);
    lcd.print("Closing Exit....");
    if(digitalRead(exit_close) == LOW){
      exit_door.stop();
      Serial.println("Door Stopped");
      return true;
    }    
  }
}

void grant_access(){
  Serial.println("Access Granted, wait for door to open");
  if(open_entry() == true){
    Serial.println("Door Open Please Enter");
    delay(1500);
  }
  if(close_entry() == true){
    Serial.println("Disinfecting.....");
    Pump(On);
    delay(1500);
    Pump(Off);
    delay(1000);
  }
  if(open_exit() == true){
    Serial.println("Door Open please exit");
    delay(1500);
  }
  if (close_exit() == true){
    Serial.println("all good");
  }
}

void setup() 
{
    //define the mode of the pins, either input or output
  pinMode(entry_open, INPUT_PULLUP);
  pinMode(entry_close, INPUT_PULLUP);
  pinMode(exit_open, INPUT_PULLUP);
  pinMode(exit_close, INPUT_PULLUP);
  pinMode(exit_close, INPUT_PULLUP);
  pinMode(motion_pin, INPUT_PULLUP);
  pinMode(lcd_pin, OUTPUT);
  pinMode(pump_relay, OUTPUT);
  pinMode(element_relay, OUTPUT);

  entry_door.begin(RPM, MICROSTEPS);
  exit_door.begin(RPM, MICROSTEPS);
  Serial.begin(9600);
  // Initiate  SPI bus  
  SPI.begin();
  // Initiate MFRC522      
  mfrc522.PCD_Init();
  //begin the LCD
  lcd.begin(16, 2);

  //turn all pins off at initial.(Active low relay, so HIGH means off)
  Pump(Off);
  Heater(Off);

  Serial.println(F("Smartech Access Control v0.2"));   // For debugging purposes
  ShowReaderDetails();  // Show details of PCD - MFRC522 Card Reader details
  lcd_light(HIGH);
  //Print welcome message
  lcd.println(" Ayoola's NFC:   ");
  lcd.setCursor(0, 1);
  lcd.println("Sanitizing Boot ");
  delay(3000);

  Serial.println("Auto Disinfectant Booth");
//close_entry();
temp = thermocouple.readCelsius();
lcd.clear();
  int i = 0;
while(temp < lowerBoundry+20){
    temp = thermocouple.readCelsius();
    Serial.print("Heatig up, Please be patient!   ");
    lcd.setCursor(0, 0);
    lcd.print("   Heating Up   ");
    lcd.setCursor(i, 1);
    lcd.print("*");
    Serial.print(temp);
    Serial.println("'C");
    Heater(On);
    delay(2000);
    i++;
    if(i >= 15){
      i = 0;
      lcd.clear();
    }
  }
  
Heater(Off);
 
  if (EEPROM.read(1) != 123) {
    Serial.println(F("No Master Card Defined"));
    Serial.println(F("Scan A PICC to Define as Master Card"));
    lcd.setCursor(0, 0);
    lcd.println("No Master CARD.!  ");
    delay(1500);
    lcd.setCursor(0, 1);
    lcd.println("Swipe a CARD to:");
    delay(2000);
    lcd.setCursor(0, 0);
    lcd.println("Swipe a CARD to:");
    delay(1500);
    lcd.setCursor(0, 1);
    lcd.println(" Save as Master!");
     delay(500);
    
    do {
      successRead = getID();            // sets successRead to 1 when we get read from reader otherwise 0
    } while (!successRead);                  // Program will not go further while you not get a successful read
   
    for ( uint8_t j = 0; j < 4; j++ ) {        // Loop 4 times
      EEPROM.write( 2 + j, readCard[j] );  // Write scanned PICC's UID to EEPROM, start from address 3
    }
    EEPROM.write(1, 123);                  // Write to EEPROM we defined Master Card.
    //EEPROM.write(0, 1);                  // Write to EEPROM to save card count.
    Serial.println(F("Master Card Defined"));
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.println("Master Tag Saved  ");
    delay(1500);
    lcd.setCursor(0, 1);
    lcd.println("Keep it Securely!   ");
     delay(2500);
  }
  Serial.println(F("-------------------"));
  Serial.println(F("Master Card's UID"));
  for ( uint8_t i = 0; i < 4; i++ ) {          // Read Master Card's UID from EEPROM
    masterCard[i] = EEPROM.read(2 + i);    // Write it to masterCard
    Serial.print(masterCard[i], HEX);
  }
  Serial.println("");
  Serial.println(F("-------------------"));
  Serial.println(F("Everything is ready"));
  Serial.println(F("Waiting PICCs to be scanned"));
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.println("Device is Ready   ");
  delay(2000); 
  lcd.clear();
}

void loop() { 
  do{
  successRead = getID();  // sets successRead to 1 when we get read from reader otherwise 0   
  lcd.setCursor(0, 0);  
  lcd.print("Swipe a Tag to:");
  lcd.setCursor(0, 1);
  lcd.print("  gain access   ");
  temp = temp = thermocouple.readCelsius();  
  Serial.print("Temp = "); 
  Serial.print(temp);
  Serial.println("'C "); 
  // For the MAX6675 to update, you must delay AT LEAST 250ms between reads!
  delay(250);
   if(temp <= lowerBoundry){
    Heater(On);
    Serial.println("Heating up.........");
   }
   else if(temp >= higherBoundry){
    Heater(Off);
   }
 
 }while(!successRead);
 
  if(successRead){
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Checking card...  ");
    delay(2000);
    if ( isMaster(readCard)) {    // If scanned card's ID matches Master Card's ID - enter program mode
        Serial.println(F("Welcome Master - Your Fare is free!"));
        uint8_t count = EEPROM.read(0);   // Read the first Byte of EEPROM that
        Serial.print(F("I have "));     // stores the number of ID's in EEPROM
        Serial.print(count);
        Serial.print(F(" record(s) on EEPROM"));
        Serial.println("");
        lcd.setCursor(0,1);
        lcd.print(" Welcome Master ");
        delay(2000);
        //card = false;
  do{
   successRead = getID();  // sets successRead to 1 when we get read from reader otherwise 0 
  lcd.setCursor(0,0);
  lcd.print("Add New a Tag or  ");
  //delay(1000);
  lcd.setCursor(0,1);
  lcd.print(" Delete old Tag   ");
  Serial.println("Place a Card to allow register or a known card to delete");
  //delay(1000);
    } while (!successRead);                 //the program will not go further while you are not getting a successful read
    
  if ( isMaster(readCard)) {    // If scanned card's ID matches Master Card's ID - enter program mode
          lcd.setCursor(0,0);
          lcd.print("Tag Registration    ");
          lcd.setCursor(0,1);
          lcd.print("Exited by Master   ");
          delay(3000);
          //card = true;
          return;
        }        
    else if ( findID(readCard) ) { // If card found, see if the card is in the EEPROM
        Serial.println(F("Tag was saved before, not a new tag"));
        deleteID(readCard);
        lcd.setCursor(0,0);
        lcd.print("  Tag Existed     " );
        lcd.setCursor(0,1);
        lcd.print("Deleting Tag...... ");
        deleteID(readCard);        
        delay(3000);
      }
     else if ( !findID(readCard)){  // If scanned card is not known add it
        Serial.println(F("I do not know this PICC, adding..."));
        lcd.setCursor(0,0);
        lcd.print("  Please wait     " );
        lcd.setCursor(0,1);
        lcd.print("  Saving Tag.......");
        delay(2000);
        writeID(readCard);
      if(writeID(readCard)){
        Serial.println(F("-----------------------------"));
        Serial.println(F("Scan a PICC to ADD or REMOVE to EEPROM"));
        lcd.setCursor(0,1);
        lcd.print(" Tag saved OK!   ");
        delay(3000);
          }        
        else{
        lcd.setCursor(0,0);
        lcd.print("Error Saving Tag");
        lcd.setCursor(0,1);
        lcd.print("Pls. Try Again..   ");
        delay(5000);        
        return;
        }
      }
    }
        
    else if ( findID(readCard) ) { // check if the card is in the EEPROM
        Serial.println(F("Welcome Passenger"));
        lcd.setCursor(0,0);
        lcd.print("Valid Tag Swiped");
        lcd.setCursor(0,1);
        delay(2000);
        lcd.print("*Access Granted***   ");
        delay(3000);
        //granted(2000); 
        grant_access();         
        }
     else  if( !findID(readCard) ){ // If scanned card is not known dont allow        
        Serial.println(F("I do not know this Tag, no entry"));
        lcd.setCursor(0,0);
        lcd.print(" Access Denied!  " );
        lcd.setCursor(0,1);
        lcd.print("**Unknown Tag!** ");
        delay(2000);
        lcd.print("Buy a Legit Tag. ");
        delay(3000);
       }
    }
}


void Pump(int state){
  digitalWrite(pump_relay, state);
}
void Heater(int state){
  digitalWrite(element_relay, state);
}

///////////////////////////////////////// Get PICC's UID ///////////////////////////////////
uint8_t getID() {
  // Getting ready for Reading PICCs
  if ( ! mfrc522.PICC_IsNewCardPresent()) { //If a new PICC placed to RFID reader continue
    return 0;
  }
  if ( ! mfrc522.PICC_ReadCardSerial()) {   //Since a PICC placed get Serial and continue
    return 0;
  }
  // There are Mifare PICCs which have 4 byte or 7 byte UID care if you use 7 byte PICC
  // I think we should assume every PICC as they have 4 byte UID
  // Until we support 7 byte PICCs
  Serial.println(F("Scanned PICC's UID:"));
  for ( uint8_t i = 0; i < 4; i++) {  //
    readCard[i] = mfrc522.uid.uidByte[i];
    Serial.print(readCard[i], HEX);
  }
  Serial.println("");
  mfrc522.PICC_HaltA(); // Stop reading
  return 1;
}

void ShowReaderDetails() {
  // Get the MFRC522 software version
  byte v = mfrc522.PCD_ReadRegister(mfrc522.VersionReg);
  Serial.print(F("MFRC522 Software Version: 0x"));
  Serial.print(v, HEX);
  if (v == 0x91)
    Serial.print(F(" = v1.0"));
  else if (v == 0x92)
    Serial.print(F(" = v2.0"));
  else
    Serial.print(F(" (unknown),probably a chinese clone?"));
  Serial.println("");
  // When 0x00 or 0xFF is returned, communication probably failed
  if ((v == 0x00) || (v == 0xFF)) {
    Serial.println(F("WARNING: Communication failure, is the MFRC522 properly connected?"));
    Serial.println(F("SYSTEM HALTED: Check connections."));  // Turn on red LED
    while (true); // do not go further
  }
}

//////////////////////////////////////// Read an ID from EEPROM //////////////////////////////
void readID( uint8_t number ) {
  uint8_t start = (number * 4 ) + 2;    // Figure out starting position
  for ( uint8_t i = 0; i < 4; i++ ) {     // Loop 4 times to get the 4 Bytes
    storedCard[i] = EEPROM.read(start + i);   // Assign values read from EEPROM to array
  }
}

///////////////////////////////////////// Add ID to EEPROM   ///////////////////////////////////
bool writeID( byte a[] ) {
  if ( !findID( a ) ) {     // Before we write to the EEPROM, check to see if we have seen this card before!
    uint8_t num = EEPROM.read(0);     // Get the numer of used spaces, position 0 stores the number of ID cards
    uint8_t start = ( num * 4 ) + 6;  // Figure out where the next slot starts
    for ( uint8_t j = 0; j < 4; j++ ) {   // Loop 4 times
      EEPROM.write( start + j, a[j] );  // Write the array values to EEPROM in the right position
    }
    //successWrite();
    num++;                // Increment the counter by one
    EEPROM.write( 0, num );     // Write the new count to the counter
    Serial.println(F("Succesfully added ID record to EEPROM"));
    return true;
  }
  else {
    //failedWrite();
    Serial.println(F("Failed! There is something wrong with ID or bad EEPROM"));
    return false;
  }
}

///////////////////////////////////////// Remove ID from EEPROM   ///////////////////////////////////
void deleteID( byte a[] ) {
  if ( !findID( a ) ) {     // Before we delete from the EEPROM, check to see if we have this card!
    //failedWrite();      // If not
    Serial.println(F("Failed! There is something wrong with ID or bad EEPROM"));
  }
  else {
    uint8_t num = EEPROM.read(0);   // Get the numer of used spaces, position 0 stores the number of ID cards
    uint8_t slot;       // Figure out the slot number of the card
    uint8_t start;      // = ( num * 4 ) + 6; // Figure out where the next slot starts
    uint8_t looping;    // The number of times the loop repeats
    uint8_t j;
    uint8_t count = EEPROM.read(0); // Read the first Byte of EEPROM that stores number of cards
    slot = findIDSLOT( a );   // Figure out the slot number of the card to delete
    start = (slot * 4) + 2;
    looping = ((num - slot) * 4);
    num--;      // Decrement the counter by one
    EEPROM.write( 0, num );   // Write the new count to the counter
    for ( j = 0; j < looping; j++ ) {         // Loop the card shift times
      EEPROM.write( start + j, EEPROM.read(start + 4 + j));   // Shift the array values to 4 places earlier in the EEPROM
    }
    for ( uint8_t k = 0; k < 4; k++ ) {         // Shifting loop
      EEPROM.write( start + j + k, 0);
    }
    //successDelete();
    Serial.println(F("Succesfully removed ID record from EEPROM"));
  }
}

///////////////////////////////////////// Check Bytes   ///////////////////////////////////
bool checkTwo ( byte a[], byte b[] ) {   
  for ( uint8_t k = 0; k < 4; k++ ) {   // Loop 4 times
    if ( a[k] != b[k] ) {     // IF a != b then false, because: one fails, all fail
       return false;
    }
  }
  return true;  
}

///////////////////////////////////////// Find Slot   ///////////////////////////////////
uint8_t findIDSLOT( byte find[] ) {
  uint8_t count = EEPROM.read(0);       // Read the first Byte of EEPROM that
  for ( uint8_t i = 1; i <= count; i++ ) {    // Loop once for each EEPROM entry
    readID(i);                // Read an ID from EEPROM, it is stored in storedCard[4]
    if ( checkTwo( find, storedCard ) ) {   // Check to see if the storedCard read from EEPROM
      // is the same as the find[] ID card passed
      return i;         // The slot number of the card
    }
  }
}

///////////////////////////////////////// Find ID From EEPROM   ///////////////////////////////////
bool findID( byte find[] ) {
  uint8_t count = EEPROM.read(0);     // Read the first Byte of EEPROM that
  for ( uint8_t i = 1; i < count; i++ ) {    // Loop once for each EEPROM entry
    readID(i);          // Read an ID from EEPROM, it is stored in storedCard[4]
    if ( checkTwo( find, storedCard ) ) {   // Check to see if the storedCard read from EEPROM
      return true;
    }
    else {    // If not, return false
    }
  }
  return false;
}

////////////////////// Check readCard IF is masterCard   ///////////////////////////////////
// Check to see if the ID passed is the master programing card
bool isMaster( byte test[] ) {
  return checkTwo(test, masterCard);
}

RFID-based Access Control With Disinfectant Booth: Explanation of Arduino Sketch

The Arduino source code written above has comments lines to explain what each line of code does. If you happen to find any problem understanding what it does, leave us a comment below for assistance.

RFID-based access control with disinfectant booth: the source code
The source code

You can download the library for the MFRC522 RFID module from Github website. The rest of the libraries can be downloaded from searching them on Google search engine. The source makes use of the the thermocouple max6675 library too.

Results and Testing

The Project design

The project was programmed to work with debit card with NFC capabilities or RFID cards. This choice was made so that people or staff could use their debit cards to gain access to the facility once it is programed into the system. When powered on, the system design LCD comes on and it tells user to swipe their card the design after greeting them and displaying the name of the project design.

check the RFID card in the database
check the RFID card in the database

As shown above, when the RFID card is swiped across the design, the LCD will display it is checking the card if it is in the database of the project design.

RFID-based access control with disinfectant booth: Access Denied for RFID card
RFID-based access control with disinfectant booth: Access Denied for RFID card

The LCD will display “Access Denied” if the card is not found to be in the DB. This will not open the door for the user after this. The user would be told that the card is an “UNKNOWN TAG”. This means the user would have to approach the administrator or admin who has a master card that he can use to assign the user an ID into the DB.

RFID-based access control with disinfectant booth: access granted

However, if the card is found in the database, the LCD will display “VALID CARD SWIPED”. The display on the LCD would change to afterwards to give us “ACCESS GRANTED”.

RFID-based access control with disinfectant booth: access granted

This granted access into the disinfectant booth will activate the opening on the booth door. Since the design was made with thread roll machine, the stepper motor would start spinning and the door would take some time to open fully.

RFID-based access control with disinfectant booth: opening the access granted door

The door of the booth opens and once, the door closes, the relay would be triggered. This will make the AC pump to pump disinfectant fluid through the fog heater. And this will be converted to got fumes that will clean the people inside the cubicle or booth.

Conclusion

The design of the RFID-based access control with disinfectant booth project design works as expected. We have been able to allow access through the entrance booth model and disinfect people inside the booth using fog disinfectants. We would like to know if you followed this blog post to achieve the same results. Drop a review in the comment section below.

Leave a Reply

Your email address will not be published. Required fields are marked *