RFID (English Radio Frequency IDentification, radio frequency identification) is a method of automatic identification of objects, in which data stored in so-called transponders or RFID tags are read or written using radio signals.
Any RFID system consists of a reader (reader, reader or interrogator) and a transponder (aka RFID tag, sometimes the term RFID is also used -tag).
The technology is used in various areas of society, but one area where it is constantly encountered is physical security.
An example of this is access control – allowing only authorized persons (i.e. people with the correct RFID tag) to enter an office building, garage, or other safe area. Users will have an RFID tag or card that they need to attach to the RFID reader. If the tracking number is correct, access will be granted. If it is incorrect, entry will be denied.
In this article, we will look at a locking device that works using this technology. This is a demo model, and the user can adapt the device to suit his needs.
Tools and materials:
-RFID reader and writer, compatible with Arduino or alternative;
-Arduino Maker Uno; -USB power supply; – Servo SG90; -10 jumpers;
Step one: getting started
Before you start working with the RFID module, you need to read the instructions on pages 3 and 4 of the user manual, which can be found on the manufacturer's website. They describe in detail how to get started with the software, correctly connect the module to the Arduino and how to determine the identification number on the RFID tag and card.
Step two: building
The box must have holes for the clips, located directly opposite each other.
To the cover boxes will be attached to Arduino, RFID reader, power supply, servo ..
Servo must be located in the center of the lid so that the stoppers that go into the holes when the lock is closed can go into both holes at the same time.
To the servo lever locking the strips are attached with rods. In this case, ordinary paper clips are used.
Servo power supply connects to 5V and GND of Arduino. Signal wire to pin 3 of Arduino
Step three: code
The software is written in the Arduino IDE. Make sure the device and port are set to the correct values in the Tools menu.
The code can be downloaded below.
//The required libraries for the program #include & lt; SPI.h & gt; #include & lt; RFID.h & gt; #include & lt; Servo.h & gt; //Setup arduino pin definitions #define SS_PIN 10 #define RST_PIN 9 #define SERVO_PIN 3 #define BUZZER_PIN 8 //Initialise the RFID reader RFID rfid (SS_PIN, RST_PIN); //Initialise an instance of the Servo class called & # 34; lock & # 34; Servo lock; //serNum is used for reading and checking the ID number int serNum & # 91; 5 & # 93 ;; //This integer should be the code of your RFID card/tag int cards & # 91; & # 93; & # 91; 5 & # 93; = & # 123; & # 123; 182,106,89,165,32}}; bool access = false; bool boxOpen = true; int attemptCount = 0; bool alarmOn = false; //Function to read the RFID card/tag and determine whether access should be granted void readCard () & # 123; if (rfid.readCardSerial ()) & # 123; for (int x = 0; x & lt; sizeof (cards); x ++) & # 123; for (int i = 0; i & lt; sizeof (rfid.serNum); i ++) & # 123; if (rfid.serNum & # 91; i & # 93;! = cards & # 91; x & # 93; & # 91; i & # 93;) & # 123; access = false; break; } else & # 123; access = true; }} if (access) break; }}} void setup () & # 123; //put your setup code here, to run once & # 58; Serial.begin (9600); SPI.begin (); rfid.init (); lock.attach (SERVO_PIN); lock.write (5); } void loop () & # 123; //put your main code here, to run repeatedly & # 58; //The & # 34; if & # 34; statement only runs if an RFID card/tag is detected if (rfid.isCard ()) & # 123;/* * Check whether the read card serial number matches the saved serial number * If the serial number is incorrect, access = false, otherwise access = true */readCard ();/* * If access is set to true and the box is currently locked, the servo will move to unlock the box. * If access is set to true and the box is currently unlocked, the servo will move to lock the box. * If access remains false, a warning buzzer will sound. * Each time an attempt is wrong, a count is increased. Once this count reaches 3, an alarm will sound. * The alarm can only be silenced by using the correct RFID card/tag. */if (access) & # 123; attemptCount = 0; if (! boxOpen) & # 123; lock.write (5); boxOpen = true; delay (1000); } else & # 123; lock.write (45); boxOpen = false; delay (1000); }} else & # 123; attemptCount = attemptCount + 1; if (attemptCount & lt; 3) & # 123; tone (BUZZER_PIN, 330, 500); delay (250); tone (BUZZER_PIN, 311, 500); delay (250); noTone (BUZZER_PIN); } else & # 123; alarmOn = true; while (alarmOn) & # 123; tone (BUZZER_PIN, 784, 1000); delay (250); tone (BUZZER_PIN, 659, 1000); delay (250); noTone (BUZZER_PIN); if (rfid.isCard ()) & # 123; readCard (); } if (access) & # 123; attemptCount = 0; alarmOn = false; }}}}} rf
After the program has been loaded into the Arduino, you can connect the power supply and check the operation of the device. When you bring the RFID tag to the reader, the servo should turn and the cover can be removed from the box. If the label is unreadable, a beep will sound.