Access Control System with NFC

Home Security: Configuring Access Control System with NFC and Micro Linear Actuator
By: Lasse Jespersen

Considering the vulnerability of standard North-American locks, using a key alone does not secure your home safely. Adding an access control system with NFC will add an extra level of security that should deter would-be thieves. Here we will go over how to set that system up using a micro linear actuator as the extra locking bolt, which is controlled by NFC tags and programmed using Arduino.


Access Control System with NFC

Access control systems with NFC (RFID) is already a standard. In most places where security matters, such as government buildings and larger businesses, either a special tag or card is used alone to gain entry, or both a key and a tag must be used. The tags conveniently allow logging of who comes and goes, logging of unauthorized access attempts, and are generally much more flexible than a key for a mechanical lock.

For homes and smaller businesses, lock bumping is more of a concern, since it is quick, effective way to pick a lock, and not as loud as the name implies. An experienced thief (or lock enthusiast) can open even high security locks with custom bump keys with 3-4 raps with a small rubber mallet. The keyway can be observed when planning entry, blanks can be bought at low cost, and the bump keys can be made manually with some experience.

Another application I found myself wishing for once upon a time, was much more a nuisance than a real cause for concern – my girlfriend’s teenage son had decided to throw a BIG party. When we got home, there was a sticky mess on every inch of the floor, in every room in the house. I wish I had set up an NFC access system for the sake of avoiding that disaster.

Example Access Control System with NFC:

  • Child A, B, C and Parents can access his/her room, but not the room of any other child or adult.
  • Adults can access the rooms of any child and their own rooms.

This application may be rather extreme, but I would have liked that setup back then. All humor aside – apart from bumping, a more silent threat is the proliferation of lockpicking equipment through innumerable, easily accessible online shops. Standard North-American locks do not have a good track record, generally speaking, as they are quick and easy to pick.

Configuring Access Control System with NFC

I don’t recommend relying on an NFC access system alone, but I would suggest to use it in conjunction with a mechanical lock. Having an NFC tag on your keyring makes it all the more convenient, costing only one or two extra seconds when you are at your front door.

Tags are not limited to the kind that fits in keyrings, or cards which fit in your wallet; you can even get tiny sticker tags which you can attach to the back of your phone, under its cover, and swipe it across the NFC panel to unlock the door bolt. Of course, the bolt – held securely by a micro linear actuator – will not respond to bumping, or picking.

Adding more tags is as simple as reading them via the serial monitor. This program prints out the user IDs of tags it reads over the serial port, so simply open Serial Monitor in Arduino->Tools. Add new tags to the array uidsKnown in the program, and they will be able to lock or unlock your NFC access system.

Components needed:


If you don’t have the Arduino program installed, go to and click on your desired platform. It is available for Linux (32/64/ARM), Mac OS X (>=10.7) and Windows – the latter does not require administrative privileges to install, though it is more convenient if you have them. Choose ‘Windows Installer’ if you can install programs on your computer, or ‘Windows Zip file for non admin install’ if you either don’t wish to clutter up your Program directories or do not have the necessary privilege.

Only one Arduino library is needed: Elechouse PN532, available at

Once you have downloaded it, open it with your archive manager and 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.

I have tested this with Arduino 1.6.9 and 1.0.5. I highly recommend Arduino 1.6.9. You can see which version you have installed by under Help->About Arduino.

As for the Elechouse PN532 module itself, you can opt for HSU mode, SPI mode, or I2C mode. I used I2C mode because I plan to extend this hardware configuration with a few other bits and bobs, and particularly the SD module I have laying around would benefit from being alone on the SPI bus. HSU mode will require you to give up your TX1, RX0 pins, and instead use SoftwareSerial for debug output. I2C worked well enough, and there’s no reason to set up SoftwareSerial unless you have a suitable serial cable available. Pay attention to the small switches on the module. Mine were covered beneath a thick brown strip of insulating tape. Here you select HSU (default), SPI or I2C. Slide the top switch to its right position, and leave bottom one at its left position if you want I2C mode. Then you will not need to modify this sketch at all. If you do want another mode, have a look at the examples for PN532 in your Arduino libraries folder.

Wiring the System Together

Copy the accessControlNFC sketch on this page into your Arduino sketch folder and open it. Even if you upload it to an Arduino now, it will not run in any meaningful way until you have wired it all up. Doing so requires no previous knowledge of electronics or programming. Personally, I always find the code and circuitry others make challenging and often irritating until I’ve had my hands dug into the muck of it – so do not worry if it seems unfamiliar.

Download accessControlNFC sketch here

First insert the Arduino Nano into the breadboard, making sure that the two rows of pins are on either side of the furrow in the middle. Also make sure that the USB mini port faces outward from the breadboard, so you do not clutter up your wiring by having a USB cable running through everything.

Secondly, place the PN532 module by the side of the breadboard. It does not need to be inserted, but if you wish to keep it tidy, first solder the SPI header pins facing downwards, so they will make good connections. In I2C mode you need only wire the SDA pin to A4 of the Arduino, and the SCL pin to A5. I2C requires 5V, so wire the VCC pin to 5V on the Arduino, and GND goes to GND. Check if the module is set to I2C mode, on the small switches which read ‘NO KE’. There is a mapping for the various modes. By default it is set to HSU mode. You want to set the switches to ‘0 | 1’ – Which means that 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.

Next wire up the RGB LED. We only need to display two colours; red and blue. From left to right (the LED has a flat side on its head) the pinout is RED, GND, GREEN and BLUE. Wire 5V to GND (Common anode) and set a 220 ohm resistor in series from pin 1 to D9 on your Arduino. Next, set a 220 ohm resistor in series from pin 4 to D8 on your Arduino.


Now, take the dual channel mechanical relay, and look at it carefully. On the relay channels, there is text like ‘NO1’, ‘COM1’, ‘NC1’ et cetera.

  • NO means Normal-Open
  • COM means Common
  • NC means Normal-Closed

It helps to understand what the effect of wiring to these terminals is. Normal-open is the port to insert a wire into if you want it to be ON when you activate that relay channel. When it is activated, you continue the circuit via the COM port, and from there to your motor, or whatever you need to power. NC is similar to NO, it just completes a connection when the relay is OFF instead of ON.

We are going to do something slightly unusual with this relay. Usually H-bridges and motor shields are reserved for super-fast operation, but since we just need to switch polarity based on a condition (a successful swipe of tag or card), we can use this relay as an H-bridge.

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

When it is all correctly wired up – refer to the instructions above if you have any problems – you will have a raw but functional access system for your home and family. It will work well supplementing your mechanical locks, and provide a good basis for growing into a larger project.


See the finished concept in action:



So, what comes next?

Easy addition and removal of authorized tags and cards using a master card, which updates a binary database on MicroSD. Precise timekeeping and logging to MicroSD of both correct and bogus reads. Perhaps support for better cards. Instructions for how to build this system into a pretty little box that your wife will permit you to mount on the wall. That is what comes next.



    1. Hi Winson,

      Thanks for the comment – glad you like the post. You’re right we forgot the sketch! I’ll find it and add it shortly – and let you know when it’s done. Sorry for the mistake and thanks for catching it! And since you like this article, I should mention we have more parts to the NFC project coming soon too.

    2. Hi Winson, we have added the access control sketch now so you can download it from the page (just under the heading “Wiring the System Together”)

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.