Introduction: How to Make an Access Control System Using NFC

About: Mod Your World. We are a small team of designers and engineers with a passion for automation. We carry a very select set of mini and micro automation parts.

Access control systems using NFC/RFID are already common among multiple industries. Government buildings, large businesses and hotels (to name a few) use a special fob/tag or card to gain entry or combine the use of both a key and a fob/tag/card for extra security measures. Using NFC/RFID tags also adds the convenient tracking of who comes and goes and at what time.

Such security measures are easy to incorporate at home by setting up an access control system using NFC/RFID in combination with your current /existing lock. Either system (lock or NFC) are quite vulnerable on their own, but when combined you gain that extra level of security that could mean the difference of being robbed or the intruder moving on to an easier target.

Side Note:

Another useful application would be to set up an NFC/RFID access system for security INSIDE the home - to keep out unwanted children or party guests from certain rooms or cupboards (secret room anyone?)

The beauty of this system is how affordable and simple it is. With some basic wiring and programming of the proper devices/equipment, you could have this set up in a few hours. Once it’s set up, just add the programmed NFC fob or card to your keychain or attach a sticker to your phone. If you use Android, you could use the already accessible NFC function to unlock the security system. You can add and remove several tags so that each family member can have their own. (This can also track when your kids come home and leave - versus when they SAY they do).

Adding this 2-step security measure of the lock and NFC combination only takes a few more seconds to enter your home, but it could mean the difference of being robbed or not.

Parts Required:

Get the complete NFC Access Control System package here (available early 2017)

Programs Required:

Copy PN532, NDEF, PN532_HSU, PN532_SPI and PN532_I2C to your libraries folder. If the Arduino program is open, close it and start it up again.

Note: Arduino 1.6.9 should give you the best results vs. 1.0.5.You can see which version you have installed under: Help->About Arduino.

*The linear actuator used for Instructable was merely for proof of concept, prior to receiving stock of the higher quality actuators we carry now. New images and video will be updated soon.

Step 1: Prep PN532 Module

For the Elechouse PN532 module, you can choose from 3 modes:

  • HSU mode
  • SPI mode
  • I2C mode

For this instruction we used I2C mode. HSU mode requires the use of the TX1, RX0 pins and SoftwareSerial for debug output. I2C works fine and there's no need to set up SoftwareSerial.

Select your desired mode, HSU (default), SPI or I2C. Move the top switch to the right position, leaving the bottom one at the left position if you plan to use I2C mode.

If you do use I2C mode then you will not need to modify this sketch. But if you decide to use a different mode, you will need to make some modifications. Take a look at the PN532 examples in the Arduino libraries folder.

Step 2: Wiring It Together

Copy the accessControlNFC sketch into your Arduino sketch folder and open it. You can go ahead an upload it to the Arduino if you want. It won’t do anything until it’s all wired up.

Download accessControlNFC sketch here

First connect the Arduino Nano to the breadboard. Make sure the two rows of pins are on either side of the furrow in the middle. It’s prudent to also face the USB mini port outwards, facing away from the breadboard. This is done to keep things clean and don’t clutter up the wiring by having a USB cable running through it all.

To prepare the PN532 module for wiring, place it beside the breadboard. It doesn’t need to be inserted, but in order to keep it tidy, you may want to first solder the SPI header pins facing downwards. Doing so will ensure good connections.

For I2C mode, wire the PN532 module as follows:

  • SDA pin to A4 of the Arduino
  • SCL pin to A5
  • I2C requires 5V, so wire the VCC pin to 5V on the Arduino
  • GND goes to GND

Make sure the module is set to I2C mode on the small switches that read 'NO KE'. There’s a mapping for the various modes. By default it’s set to HSU mode. Set the switches to '0 | 1' - This means the top switch must be in its left position and the bottom switch must be in its right position.

That's it for the PN532 module.

Step 3: Wire Up the RGB LED

Next wire up the RGB LED. We only need it to show two colours: Red & Blue

From left to right (the LED has a flat side on its head) the pinout is: RED, GND, GREEN, BLUE

Wire 5V to GND (Common anode) and set a 220 ohm resistor in series from pin 1 to D9 on the Arduino. Then, place a 220 ohm resistor in series from pin 4 to D8 on the Arduino.

Step 4: Set Up Dual Channel Relay Module

Now, we set up the dual channel mechanical relay. On the relay channels, in front of each terminal, you will see text like 'NO1', 'COM1', 'NC1' (or something similar).

  • NO means Normal-open
  • COM stands for common
  • NC stands for Normal-closed.

It’s useful to understand what happens when wiring to each of these terminals:

Normal-open is the port to connect a wire if you want it to be ON when you activate the relay channel. When it’s activated, the circuit continues through the COM port to the motor (or whatever it is you’re powering).

NC is similar to NO. It completes the connection when the relay is OFF instead of ON.

We’re going to do something a little different than normal with this relay. Typically, motor shields and H-bridges are used for high-speed performance. But since we only need to switch polarity based on an event (the tap of a card or tag), we can simply use the relay as an H-bridge instead.

Wire it up as follows:

  • Arduino 5V to relay VCC pin
  • Arduino GND to relay GND pin
  • Arduino D7 to relay S1 pin across a 220 ohm resistor
  • Arduino D6 to relay S2 pin across a 220 ohm resistor
  • 12V GND to NO1
  • 12V GND to NO2
  • 12V VCC to NC1
  • 12V VCC to NC2
  • 12V VIN/VOUT from COM1/COM2, alternating, but never both ON or OFF simultaneously.

Once it’s all properly wired, you’ll have a raw but functional access control system with NFC to add an extra level of security for your home and family.