Arduino RFID Door Lock

by:DIgao     2020-06-29
Here is a list of parts and links for SparkFun.
Where I bought them
This is the basic part set you need to build, arduino and a circuit that reads the RFID tag into the arduino.
I think you already have the breadboard, the power and the cable.
The Arduino boot loader costs $4.
95 Crystal 16 MHz $1.
50 capacitor ceramic 22pF $0. 25 (x2)
Resistance 10 k Ohm 1/6 W p $0.
25 mini button switches $0.
Three-Way output led rgb-Diffused $1.
Any of these, 20 have a better range, and 12 are the smallreader reader ID-12 $29.
95 RFID reader ID-20 $34.
95 RFID reader broke through $0.
95 broken head-Straight $2. 50RFID Tag -125kHz $1.
95OtherTIP31A transistor (
$ Month for Radio shack\'s/local electronics store. 50)
Door lock from ebay.
Door failure safety access control power strike v5 NO $17. 50 (kawamall, bay)
The first step in building an RFID door lock with a basic Arduino is to assemble the basic working arduino into a breadboard.
Most Arduino pre-
The shiny ATMega 168 chip comes with the default flashing program pre-installed.
Connect the LED to the digital output 13 and verify that everything is OK.
If we use a normal arduino with a built-in USB programmer, the hardware part of this RFID reader will be too simple.
Since I plan to put it on the wall and not touch it anymore, when I can buy a $5 ATMega 168 and make a much smaller one, I don\'t want to use a 30 custom PCB with a built in size.
Since I choose to do a basic Arduino circuit myself, I need an external USB-
> Serial FDIT programmer.
I have included the Eagle Schematic of the controller and the power supply is made of a 7805 voltage regulator.
I used the breadboard power supply during the test.
To get the arduino up and running, what you really need is the iphone168 with arduino Software, 2x 22pF capacitors, 16 mhz crystals, 10 k ohm resistors, buttons and breadboards.
This is well known, but I have included the entire schematic diagram of the circuit.
The Arduino will trigger 4 outputs, 1 red/green/blue LEDs each, triggering the TIP31A to send 12vDC to the door lock.
Arduino receives serial data from ID-on its Rx line20 RFID reader.
Now that you \'ve boarded the arduino bread and started working, you can put together the RFID reader part of the circuit that contains the ID10 or ID-
20 and rgb led showing Circuit status.
Keep in mind that the reader will be on the outside and separate from the controller inside so that no one can easily break in.
To build this, we will send 5 v/ground from the primary breadboard to the secondary breadboard we are building the reader.
In addition, 3 + wires are sent from the arduino output pin to control the rgb led, one for each color.
Another wire of Brown in the picture will be serial connection of ID
Call with arduino\'s Rx serial input.
This is a very simple connection circuit.
A few points on the get resistor and ID of the LED-
Connect the 20 to the ground/5 v to set the correct state.
To make the ID easier10/ID-
Sparkfun sells a breakout board that allows you to connect longer needles that are spaced apart to fit the breadboard.
This part and pinheaders are listed in the parts list.
The schematic diagram should be forward and easy to understand.
It\'s time to program your arduino.
Using the basic arduino can be a bit tricky, and you may need to press the reset button multiple times before and during the first part of the upload.
One very important thing to keep in mind is that if you keep opening the ID for the time being, you will receive an upload error
20 serial lines of Arduino\'s Rx line.
It has only 1 Rx input to upload the code to talk to the programmer.
Disconnect ID-
When programming, reinsert it when you\'re done.
I used an FTDI programmer that allows you to program arduino via USB with only 4 wires.
The controller schematic shows a pin head connection that allows you to insert a pin head connection directly.
Sparkfun also sells this part, but many people may already have it.
You can easily upload my code to your arduino and never look back, but what\'s the fun about that?
Let me explain the basic idea of how it works.
First of all, I don\'t want any external buttons/switches/etc, I don\'t want to re-program arduino every time I want to add a new card.
Therefore, I would like to use RFID only to control the operation of the circuit and the control of the door lock.
The program opens the blue LED, indicating that it is ready to read the new card.
When the card is read, it determines whether it is a valid card by comparing what it reads with the list of valid cards.
The arduino turns off the blue LED and turns on the green LED for 5 seconds if the user is valid.
It also turns on another output high in 5 seconds.
This output is connected to the TIP31A transistor, allowing the tiny arduino to control a larger 12 v 300 mA door lock without damage.
Lock the door after 5 seconds
The lock and LED go back to blue and wait for another card to be read.
If the card is invalid, then the LED turns red in a few seconds, then goes back to blue and waits for another card.
Even if the arduino is powered off or reset overnight, it is important that the door lock still works.
Therefore, all valid card IDs are stored in the EEPROM memory.
The company has 512 bytes of EEPROM memory.
Each RFID card has a 5 hex byte serial number and a 1 hex byte check and which we can use to verify the ID-
And arduino.
By using the first byte as a counter, the valid card is stored in the EEPROM.
For example, if there are 3 valid cards, the first byte stored in the EEPROM will be 3. EEPROM. read(0); = 3.
Knowing this, and the fact that each ID is 5 bytes long, we know 1-
5 is card 1, 6-
10 is card 2 and 11-15 is card 3.
We can do a loop, go through 5 bytes of EEPROM at a time, and try to find the card read by the card reader.
But how do we add the new card to the EEPROM after the circuit is installed? ?
I have read one of the RFID cards I have and hard coded them as the main RFID card.
Therefore, the main card can still work even if the entire EEPROM is erased.
Whenever a card is read, it first checks if it is the main card, and if it is not, then it continues to check if it is a valid card.
If the card is the main card, we get the arduino into \"programming mode\" and it flashes RGB, waiting for another valid tag to be read.
The next tag read is added to the next idle point in the EEPROM, and if the card is not already present in the EEPROM memory, the counter will increase by 1.
The reader then returns to normal mode, waiting to read the new card.
At the moment, I haven\'t programmed a way to delete the card, because the reason for deleting the card is likely to be that the card is lost or stolen.
Because this is likely to be related to 1-
The easiest thing 10 people can do is to hard program a master erase card that will erase all the cards from the EEPROM and then re-add all the cards, which takes only a few seconds.
I have added the code for erasing the EEPROM, but I have not implemented this feature yet. .
The code is attached to the text file along with a copy of the part list.
This is just some cool thing you can do with RFID.
You can further expand with LCD output, who enters and when to log in, network/twitter connection, etc.
I plan to make the finished PCB of this circuit.
I \'ve never done a PCB before, so I\'m still working on the design and layout of the parts.
I will post them as well once I finish them.
I encourage anyone to change the code I wrote and do something cooler!
Custom message
Chat Online 编辑模式下无法使用
Chat Online inputting...