A set of RFID access control solutions based on rc522 module DIY
[ad_1]
In order to solve the problem that the landlord forgets the key in the dormitory daily, but the Yangchengtong and mobile phone will not forget, so the rfid unlocking function is added to the dormitory door.
Basic function: After this project uses rc522 to read the id of the rfid card, compare it with the Id number written in the program in advance. If the comparison is successful, the door will not be opened when the door is opened. The screen display can be added later, and the door opening log can be recorded to the tf card. It is poor now, but the power consumption will become larger in this way, resulting in the need for a usb charger to supply power. Now an 8000 mAh power bank can be used stably for one week.
The original arduino uno to be prepared
rc522 module
A steering gear that is strong enough to open your door
Various usual m1 cards (Yangchengtong, community access control, mobile phones with nfc, meal cards, etc…)
(The original picture above is from the Internet)
The basic process of making
1. Hardware wiring diagram and schematic diagram
#include “SPI.h”
#include 《RFID.h》
#include 《Servo.h》
Servo myservo;
extern uint8_t SmallFont[];
RFID rfid(10,8); //D10–connect to SDA, D8–connect to RST D13–connect to SCK D11–connect to MOSI D12–connect to MISO RQ not connected
unsigned char serNum[5];
void setup()
{
Serial.begin(9600);//Serial port is used to read the card number that needs to be added, and then manually write it into the program
myservo.attach(9);//Servo pin position 9
myservo.write(0); //Servo initialization 0 degree
SPI.begin();
rfid.init();
}
void loop()
{
long randNumber = random(0, 20);
unsigned char i, tmp;
unsigned char status;
unsigned char str[MAX_LEN];
unsigned char RC_size;
//Find a card
rfid.isCard();
//Read the card number
if (rfid.readCardSerial())
{
Serial.print(“your card id is: “);
Serial.print(rfid.serNum[0]);
Serial.print(“, “);
Serial.print(rfid.serNum[1], BIN);
Serial.print(“, “);
Serial.print(rfid.serNum[2], BIN);
Serial.print(“, “);
Serial.print(rfid.serNum[2], BIN);
Serial.print(“, “);
Serial.print(rfid.serNum[4], BIN);
Serial.println(” “);
//The following is the area to change the card number
if(rfid.serNum[0]==30||rfid.serNum[0]==148||rfid.serNum[0]==136||rfid.serNum[0]==161||rfid.serNum[0]==68){//First screening
for(int i=0;i《100;i++)
{
if(rfid.serNum[0]==30||rfid.serNum[0]==117||rfid.serNum[0]==155)//Second screening, support one person and one number
{
Serial.println(“Welcome test 1”);
myservo.write(180);
}
if(rfid.serNum[0]==148||rfid.serNum[0]==68||rfid.serNum[0]==161)//rfid.serNum[0]==161 This 0 is the id position, you can change it by yourself
{
Serial.println(“Welcome test 2”);
myservo.write(180);
}
if(rfid.serNum[0]==136)
{
Serial.println(“Welcome test 3”);
myservo.write(180);
}
}
delay(1000);
myservo.write(0);
Serial.println(“closed”);
}
}
if (!rfid.readCardSerial()){
}
rfid.halt(); //sleep
}
This source code is compiled normally in arduino ide1.0.6
Reference
Thanks to ID: Similar items on the Internet provided by Shutang
The rfid library found on the Internet greatly speeded up my production process.
Actual combat drill
1. Power bank solution
The shell is a modified word of Jinsha Chocolate
This is in an unfinished state, a paint will be sprayed on the back and taped tightly
The installation diagram of the old lock steering gear in our school↑
2. Usb charger power supply scheme
rc522 installation diagram
[ad_2]