Things used in this project

Schematics

RFID Access Controller
This is a scematic of main system. This office consisted of an external door and an internal door. S1 and S2 are two reed swtiches installed with extermal door so that it informs access controller to open internal door once RFID access is granted.
This schematic has covers failure plan where for any issues with system, the guard can insert special fuse F1 and enable the manual buttons S3 and S4 to deactivate the lock.
Untitled sketch schem fm7c8qkksa

Code

RFID Access ControllerC/C++
This code is built to read the RFID/NFC card and then see if the visitor is authorised or no. For an authorised person, it will activate a relay that will deactivate the lock to open the door.
#include <Wire.h>
#include <SPI.h>
#include <LiquidCrystal.h>
#include <Adafruit_PN532.h>

#define PN532_SCK  (2)
#define PN532_MOSI (3)
#define PN532_SS   (4)
#define PN532_MISO (5)

Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup(void) {
    lcd.begin(16, 2);
    nfc.begin();
    nfc.SAMConfig();
    pinMode(2,OUTPUT);
    pinMode(3,OUTPUT);
    pinMode(4,OUTPUT);
    pinMode(5,OUTPUT);
    digitalWrite(2,LOW);
    digitalWrite(3,LOW);
    digitalWrite(4,LOW);
    digitalWrite(5,LOW);
}

void loop(void) {
  uint8_t success;
  uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };  // Buffer to store the returned UID
  uint8_t uidLength; 
    digitalWrite(2,LOW);
    digitalWrite(3,LOW);
    digitalWrite(4,LOW);
    digitalWrite(5,LOW);
    success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
    if (success)
    {
        NfcTag tag = nfc.read();
        NdefMessage message = tag.getNdefMessage();
        int recordCount = message.getRecordCount();
        for (int i = 0; i < recordCount; i++)
        {
          NdefRecord record = message.getRecord(i);
          int payloadLength = record.getPayloadLength();
          byte payload[payloadLength];
          record.getPayload(payload);
          String payloadAsString = "";
          for (int c = 1; c < payloadLength; c++) 
          {
            payloadAsString += (char)payload[c];
          }
          if (payloadAsString=="Zeeshan"){
            digitalWrite(2,LOW);
            digitalWrite(3,HIGH);
            lcd.clear();
            lcd.setCursor(0, 0);
            lcd.print("Access Granted!");
          }
          else if (payloadAsString!="Zeeshan"){
            digitalWrite(4,LOW);
            digitalWrite(5,HIGH);
            lcd.clear();
            lcd.setCursor(0, 0);
            lcd.print("You Don't have Access!");  
          }
        }  
    }
    delay(1000);
}
RFID WriteC/C++
This code is prepared to make RFID cards for the visitors
#if 1
#include <SPI.h>
#include <PN532_SPI.h>
#include <PN532.h>
#include <NfcAdapter.h>

PN532_SPI pn532spi(SPI, 10);
NfcAdapter nfc = NfcAdapter(pn532spi);
#else

#include <Wire.h>
#include <PN532_I2C.h>
#include <PN532.h>
#include <NfcAdapter.h>

PN532_I2C pn532_i2c(Wire);
NfcAdapter nfc = NfcAdapter(pn532_i2c);
#endif

void setup() {
      Serial.begin(9600);
      Serial.println("NDEF Writer");
      nfc.begin();
}

void loop() {
    Serial.println("\nPlace a formatted Mifare Classic or Ultralight NFC tag on the reader.");
    if (nfc.tagPresent()) {
        NdefMessage message = NdefMessage();
        message.addUriRecord("Zeeshan");

        bool success = nfc.write(message);
        if (success) {
          Serial.println("Success.");        
        } else {
          Serial.println("Write failed.");
        }
    }
    delay(5000);
}

Credits

Terminator 2 1200x873 pvbxjjqkvz
Muhammad Zeeshan Akram

creative and destructive design master. ability to use the brain waves for both construction and destruction

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Reducing Arduino Power Consumption
Intermediate
  • 83
  • 4

Full instructions

One the most important feature of portable electronics should be long battery life. We can reduce the current drawn by several ways.

Particle Photon Based Security System with Alerting
Intermediate
  • 1,297
  • 20

Full instructions

Be alerted to any door or window opening and closing in your house on your smart phone.

Raspberry Pi Google Assistant With Sleek Wood Box
Intermediate
  • 5,124
  • 29

Full instructions

l built a DIY Google AI Assistant using a Raspberry Pi, USB Speaker and USB microphone.

Smart and Safe Outdoor Plant Watering System
Intermediate
  • 2,466
  • 18

Monitors soil moisture and weather forecasts to give plants just the water they need. Safe garden hose hookup for season long watering.

DIY Alarm Control Panel for Home Assistant
Intermediate
  • 13,838
  • 28

Full instructions

A simple touchscreen interface, powered by a Raspberry Pi Zero, which controls the alarm in Home Assistant over MQTT.

Remote Lamp
Intermediate
  • 42
  • 0

Full instructions

How to make a lamp controlled by TV remote control.

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaFree StoreBlog