Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » Arduino+PN532 NFC Based Payment, Entrance & Security System
Arduino Projects

Arduino+PN532 NFC Based Payment, Entrance & Security System

Mamtaz AlamBy Mamtaz AlamUpdated:August 20, 20222 Comments6 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
Arduino PN532 NFC
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Overview

In this article, we will have an overview of the Arduino+PN532 NFC-based board called Maduino Zero NFC Board. The Maduino Zero NFC is an IoT (Internet of things) Solution based on the 32-bit Atmel’s SAMD21 MCU and NXP Near Field Communication Controller PN532. The customized board can be used for payment applications, entrance systems, and security system projects.

The Maduino Zero NFC is based on Arduino and users can program it with Arduino IDE. This guide helps you with the basic usage of Maduino Zero NFC along with hardware overview and programming.

While RFID technology can be used over long distances, NFC technology is limited to small distances. NFC is best used to securely transfer a range of data over short distances, hence its prevalence in access control and payment applications. On the other hand, RFID is more suited to faster-moving environments with lots of moving parts and is most often used for vehicle access control and asset management purposes.

Before moving ahead, check some of our RFID based projects like RFID Security System and also the RFID Attendance System project. You can also check the overview of PN532 NFC Module and its interfacing with Arduino in UART, I2C & SPI Mode.


What is NFC?

NFC, or near-field communication, refers to technology that allows enabled devices that are near each other to wirelessly share data. NFC technology evolved from radio frequency identification (RFID) technology and is more fine-tuned.

NFC Working

NFC operates on the principle of inductive coupling, at least for short-range implementations. This essentially involves the reader device generating a magnetic field by passing an electric current through a coil. When a tag (with its own coil) is brought nearby, the field induces an electric current within the tag. Then, once the initial handshake is complete, any stored data on the tag is wirelessly transmitted to the reader.




Customized NFC Board (Maduino Zero NFC)

Maduino Zero NFC is an Arduino-compatible small development board with NFC (Near-Field Communication). It is designed using ATSAMD21G18 controller which is actually Arduino Zero board and PN532 NFC Chip.

You can purchase this board from Makerfabs and use it for multipurpose applications.

Maduino Zero NFC

This board will be the bridge that helps you wirelessly interact with your environment, drive motors, unlock strikes, control relays, read from a temperature sensor. This is because it has built-in NFC connectivity, right out of the box.

Arduino PN532 NFC

This board has a micro USB port for serial communication and supply power. We can connect the 5V power input or a Solar Panel to charge the lipo Battery. It also has a 3.7V LiPo Battery Connector and a power switch to turn ON/OFF the module. An NFC antenna with an IPX interface is used for scanning the NFC tag. A status indicates LED is connected to D2 along with a power indication LED. An SWD switch is available on the board for downloading the bootloader. You can press a reset button on the board to reset the ATSAMD21G18 controller.

At the back of the board there is an SD Card socket. You can insert an SD Card in the socket and store the necessary data in text format.


Features

  • ATMEL SAMD21G18A: 32-bit ARM® Cortex®-M0 up to 48MHz, 256KB flash, 32KB SRAM, LQFP48
  • Powered by a lithium battery(3.4-4.2V) Or MicroUSB
  • NXP PN532, Near Field Communication (NFC) controller
  • Contactless communication at 13.56 MHz
  • PCD mode for FeliCa, ISO/IEC14443-3 Type-A, Mifare, ISO/IEC14443-4 Type-A, and Innovision Jewel cards
  • Interface: I2C/SPI/UART/ADC/DAC/I2S/38*GPIO
  • Arduino Compatible: You can play it with Arduino IDE
  • More cost-effective and high quality than Arduino Zero
  • Default baud rate: 115200bps

Warning: Don’t operate when in power supply on (That is, don’t plug or unplug the Antenna, SD Card, in case of short-circuiting that may burn the IC down.)



How to use Maduino NFC Board?

The Maduino NFC Board has a Arduino Zero controller PN532 NFC Chip. To use this board with Arduino IDE, we need to setup Arduino IDE first.


Setting up Arduino IDE

The ATSAMD21G18A board isn’t pre-installed in the Arduino IDE. So, we need to install “Arduino Zero Board” from the Board Manager.

Open the Boards Manager From the top Arduino IDE menu, select Tools-> Board-> Boards Manager… to open the Boards Manager dialog box. Then install Arduino SAMD Boards(32-bits ARM Cortex-M0+).

Once, the installation completes, you can now select the Arduino Zero board as shown in the image below. To program this Board you need to connect a Micro USB Data Cable.


Hardware Connections

First Plug a NFC Antenna to designator which shows ANT1. Then plug a Micro USB Cable to Maduino Zero NFC. You can connect a 0.96″ I2C OLED Display to the board via a 4 pin female header.

Arduino PN532 NFC Board

You can supply power with a 3.7V lithium battery after you upload the program to the board as it works between 3.4V to 4.2V. Both the battery and the MicroUSB can be used for the power supply. While MicroUSB is connected, the board will be powered by MicroUSB, while MicroUSB removed, it will switch to battery automatically.



Source Code & Programming

Select the Arduino Zero(Native USB port) board from the Arduino IDE Board menu. Then select the correct Port number as Native USB port will appear in the COM port. Now you can upload the following code to the Maduino Board.

But the Arduino IDE requires some library for compilation. Download the following libraries and add them to the Arduino IDE via Library Manager:
1. Adafruit PN532 Library: Download
2. Adafruit GFX Library: https://github.com/adafruit/Adafruit-GFX-Library
3. SSD1306 OLED Library: Download

This is the complete Arduino PN532 NFC interface code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#include <Wire.h>
#include <SPI.h>
#include "Adafruit_PN532.h"
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
 
#define PN532_SS   (9)
#define PN532_IRQ   (2)
#define PN532_RESET (11)  // Not connected by default on the NFC Shield
 
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
 
Adafruit_PN532 nfc(PN532_SS);
 
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
 
#if defined(ARDUINO_ARCH_SAMD)
#define Serial SerialUSB
#endif
 
#define STA_LED 2 //D2
 
void setup(void)
{
  pinMode(STA_LED, OUTPUT);
  digitalWrite(STA_LED, HIGH);   // turn the LED off (HIGH is the voltage level)
 
#ifndef ESP8266
  while (!Serial); // for Leonardo/Micro/Zero
#endif
  Serial.begin(115200);
  SerialUSB.begin(115200);
 
  if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS))
  {
    Serial.println(F("SSD1306 allocation failed"));
    for (;;); // Don't proceed, loop forever
  }
 
  nfc.begin();
 
  uint32_t versiondata = nfc.getFirmwareVersion();
 
  if (! versiondata)
  {
    SerialUSB.print("Didn't find PN53x board");
    while (1); // halt
  }
 
  // Got ok data, print it out!
  SerialUSB.print("Found chip PN5");
  SerialUSB.println((versiondata >> 24) & 0xFF, HEX);
  SerialUSB.print("Firmware ver. ");
  SerialUSB.print((versiondata >> 16) & 0xFF, DEC);
  SerialUSB.print('.');
  SerialUSB.println((versiondata >> 8) & 0xFF, DEC);
 
  display.clearDisplay();
  display.setCursor(0, 0); //oled display
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.print("Found chip PN5");
  display.print((versiondata >> 24) & 0xFF, HEX);
 
  display.setCursor(0, 20); //oled display
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.print("Firmware ver. ");
  display.print((versiondata >> 16) & 0xFF, DEC);
  display.print(".");
  display.print((versiondata >> 8) & 0xFF, DEC);
 
  nfc.setPassiveActivationRetries(0xFF);
 
  // configure board to read RFID tags
  nfc.SAMConfig();
 
  SerialUSB.println("Waiting for an ISO14443A card");
 
  display.setCursor(0, 40); //oled display
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.print("Waiting for NFC Card");
  display.display();
 
}
 
void loop(void)
{
  boolean result_success = 0;
  uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };  // Buffer to store the returned UID
  uint8_t uidLength;                // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
 
  result_success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength);
 
  if (result_success)
  {
    SerialUSB.println("Found a card!");
    SerialUSB.print("UID Length: ");
    SerialUSB.print(uidLength, DEC);
    SerialUSB.println(" bytes");
    SerialUSB.print("UID Value: ");
 
    display.clearDisplay();
    display.setCursor(10, 0); //oled display
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.print("UID Length:");
    display.print(uidLength, DEC);
    display.print(" bytes");
 
    display.setCursor(35, 20); //oled display
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.println("UID Value: ");
    display.setCursor(5, 35); //oled display
 
    for (uint8_t i = 0; i < uidLength; i++)
    {
      SerialUSB.print("0x");
      SerialUSB.print(uid[i], HEX);
      
      display.print(" 0x");
      display.print(uid[i], HEX);
      display.display();
    }
    SerialUSB.println("");
    digitalWrite(STA_LED, LOW);// turn the LED on (LOW is the voltage level)
    result_success = 0;
    // Wait 1 second before continuing
    delay(1000);
  }
  else
  {
    // PN532 probably timed out waiting for a card
    SerialUSB.println("Timed out waiting for a card");
  }
  digitalWrite(STA_LED, HIGH);   // turn the LED off (HIGH is the voltage level)
}



Testing & Results

After code uploads successfully, you can start the testing process. The OLED Display will print firmware version as 1.6 and will ask to scan the cards.

pn532 firmware version

Now bring some NFC Cards near the Antenna of Maduino Zero Board. The NFC Card may include your bank card or a travel card or maybe some NFC test Card.

When you put the card on the top of the antenna, it will read byte length along with the UID value & displays them on the OLED screen.

Arduino PN532 NFC Board

Sometimes the byte length might be 4 bytes or 7 bytes depending upon the type of NFC Card.

Arduino PN532 NFC Board

In case you don’t want the OLED Display for the project, you can display the UID value and byte length on the Serial Monitor.

UID Length and UID Value

This is how you can use Arduino & PN532 NFC based Maduino Zero NFC Board for payment, entrance & security System applications.


Video Tutorial & Guide

NFC Scanner using PN532 Chip & Arduino Zero Board
Watch this video on YouTube.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleMotion Detection Squid Game using ESP32 CAM & OpenCV
Next Article Collecting SHT85 Sensor Data using STM32 & Bluetooth Low Energy

Related Posts

DC Energy Meter using Arduino

Build a DC Energy Meter using Arduino – 32V/5A

Updated:August 26, 20252K
Interfacing ADXL375 Accelerometer with Arduino

Interfacing ADXL375 Accelerometer with Arduino (±200g)

Updated:June 28, 2025
PZEM-004T Arduino Energy Meter

DIY AC Energy Meter using PZEM-004T & Arduino

Updated:March 6, 20258K
Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Updated:February 2, 20259K
Password Based Door Lock Security System Using Arduino & Keypad

Password Based Door Lock Security System Using Arduino & Keypad

Updated:February 2, 20252436K
Earthquake Detector Alarm with with Accelerometer & Arduino

Earthquake Detector Alarm with Accelerometer & Arduino

Updated:February 2, 2025661K
View 2 Comments

2 Comments

  1. Firdosh on February 17, 2022 3:43 PM

    May you please do a full video tutorial on door access with the above board

    Reply
    • Admin on February 17, 2022 6:52 PM

      Yes some videos are coming soon.

      Reply

CommentsCancel reply

Latest Posts

ESP32 Fingerprint Attendance System with Live Web Dashboard

June 14, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
Top Posts & Pages
  • IoT Based PM & Air Quality Monitoring System using ESP32
    IoT Based PM & Air Quality Monitoring System using ESP32
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
    ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
  • How to use INA219 DC Current Sensor Module with Arduino
    How to use INA219 DC Current Sensor Module with Arduino
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • Designing of MPPT Solar Charge Controller using Arduino
    Designing of MPPT Solar Charge Controller using Arduino
  • L293D Dual H-Bridge Motor Driver IC Pins, Circuit, Working
    L293D Dual H-Bridge Motor Driver IC Pins, Circuit, Working
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (205)
    • ESP32 MicroPython (7)
    • ESP32 Projects (82)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.