Hardware components | ||||||
![]() |
| × | 1 | |||
| × | 1 | ||||
![]() |
| × | 1 | |||
Software apps and online services | ||||||
![]() |
|
Security is a main concern for any office in order to protect not only the private data but also the staff working over there. This project has bee done for one of such offices that required a smart access control.
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.
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.

RFID Access Controller
C/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);
}
#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);
}
Comments
Please log in or sign up to comment.