RFID Access control
Some of you may wonder how on earth do I come with the idea of programming an alarm. Well, the reason is simple: my motorbike was stolen from my garage.
When I realised that the theft happened right under my nose is when I decided that I had to do something. I couldn’t retrieve my bike, alright, but I was gonna make sure never to happen again.
On this post, I will explain how did I programmed and built-up my own access control.
WHAT’S THE PROJECT ABOUT?
This device performs an access control by 125 kHz RFID tags as the one shown in Figure 1. It consists of a microcontroller and a RFID reader which are communicated through a serial link.
HOW IS IT GOING TO WORK?
When an accepted RFID tag is swiped around the reader, the device grants access to a protected zone by switching on a relay that power on the lights.
The capabilities of this device can be further increased by integrating an electro-mechanical locking mechanism to the door. This could be locked and unlocked by two additional digital outputs.
WHAT DID I USE?
- 2 boards of the following sizes
- 70×45 mm
- A dc power supply voltage between 7-25V (min-max) and 5-500mA (min-max)
The hardware is divided into two boards as can be seen on Figure 2. This architecture increases the safety as the mainboard (board 1) can be safely placed (or even hidden) inside the protected area whereas the human-machine interface (HMI) board (board 2) can be left exposed in the un-protected area.
The board 1 acquires all the inputs (such as door opening) and execute the algorithm activating the outputs (alarm) as required; even if board 2 has been stolen or broken. This guarantees that even in the case of vandalism that may destroy the exposed part (board 2), the alarm will still be activated if necessary.
The board 1 comprises the microprocessor, the digital inputs (DI) and digital outputs (DO) as well as the communication links with the board 2. This board receives the input voltage (Vin) and generates the 5 Vdc required by the microprocessor.
Note: In the initial prototypes of this board, there was no onboard 5V voltage regulator so an external one was used to avoid relying on the microcontroller regulator. In this situation, the Vin pin in the microcontroller should be cut and left floating and it should be powered from the external voltage regulator at 5V (see Figure 4).
LINKS WITH BOARD 2
The link with the board 2 is splitted in two connectors for the sake of routing simplicity. These can be highlighted in Figure 5.
The connector highlighted in red implements the communication with the RFID module whereas the one in blue sends the power supply to the board 2 and the communication with the LCD display.
Both links can be accommodated using a single UTP8 cable with lengths up to 2,5 m have been properly tested and validated.
The pin Tx in the red connector is not used so it should not be wired.
DIGITAL INPUTS (DI)
The board includes two digital inputs that will gather the information about the status of the door (pins DOOR and DOOR1 in Figure 3) and the status of the manual key that turns the unit into manual mode (pins KEY and KEY1). The digital inputs are optocoupled as seen on Figure 6.
Note: Here, the Vcc tag equals Vin so the value of the limiting resistors R1 and R2 should be chosen according to the actual value of Vin (12V usually).
DIGITAL OUTPUTS (DO)
The board includes two digital outputs that will control the status of the lights (pin LIGHT in Figure 3) and the status of the alarm (ALARM pin).
Additionally, two more digital outputs are prepared to include an electro-mechanical lock system to the door (pins LOCK and UNLOCK); but currently these feature has not been implemented in the firmware.
The digital outputs are conceived to be used with standard relay boards as the one shown in Figure 7. These can be sourced from many internet suppliers at a low price.
To operate with these relay boards, the following cabling should be performed (Figure 8):
- Digital outputs driving signals (green and blue traces)
- Driving signals voltage (yellow trace)
- Relay coils voltage (red and black traces)
Note 1 : The blue bridge shown in Figure 8 should only be used in case the voltage of the coils of the relays coincides with the driving signals voltage (5V). In any other case, it should be removed.
Note 2: Normally these relay boards have inverted input; i.e., to activate the relay, a logic 0 should be applied to the corresponding driving signal. This is how the firmware is programmed as default; in case a non-inverted output is required, the values of the code tags __RELAY_ON__ and __RELAY_OFF__ should be exchanged.
The board 1 includes four 2 mm diameter holes to be fixed to a frame by means of plastic spacers. The pattern for the holes is shown in Figure 9.
HOW MUCH IS ALL THIS?
This is how much he components required to build up the board 1 cost:
- 1 unit Arduino nano v3: 5,80€ (You can find it here)
- 2 units 4N25 Optocoupler: 0,17€ (You can find it here)
- 1 unit LM7805 5V voltage regulator: 0,09€ (You can find it here)
- 2 units 1 kOhm resistor: 6,74€ (You can find it here)
- 1 unit 2 channel 12Vdc relay board: 1,84€
The second part of the explanation will be about board 2. We pretty much finished the hands-work on board 1 and now we just have to manufacture board 2 and connect them both.
As I have mention above, board 2 is going to comprise the RFID reader and an LCD display that shows information about the status of the device.
This board is intended to be used with an ID-12LA reader and a breakout board but you can use other serial interfaced readers as well. I have been testing succesfully the MFRC-522 (which is a more powerful yet cheaper RFID reader/writer) using the I2C interface.
This board receives the power supply from the link with board 1 and converts it to a 5 Vdc stabilized voltage by means of its onboard regulator (U2_1 in Figure 10).
Board 2 also includes a buzzer (SG1 in Figure 10Figure 10) that gives a sound feedback when a RFID tag has been read. It is additionally used to give some other information to the user such as that a counter is about to finish.
LINKS WITH BOARD 1
The links with the board 1 are highlighted in the next figure with corresponding colors to Figure 5.
The board 2 includes four 2 mm diameter holes to be fixed to a frame by means of plastic spacers. The pattern for the holes is shown in Figure 11.
HOW MUCH IS THIS?
The minimal components to have an operational board and some additional features are included below along with how much I paid for them.
- 1 unit ID-12LA: 29,95€ (You can find it here)
- 1 unit ID-12 breakout board: 1,95€ (You can find it here)
- 1 unit LM7805 5V voltage regulator: 0,09€ (You can find it here)
- 1 unit 5 V buzzer: 0,14€ (You can find it here)
- 1 unit 4N25 Optocoupler: 0,17€ (You can find it here)
- 1 unit 1 kOhm resistor:
- 1 unit I2C interfaced LCD: 1,86€ (You can find it here)
- 1 unit LED
- 1 unit 470 Ohm resistor
The following figure summarizes the cabling between both boards.