Jannah Theme License is not validated, Go to the theme options page to validate the license, You need a single license for each domain name.
Arduino Projects

PN532 RFID NFC Module with Arduino, How to use HSU UART, SPI, & I2C

PN532 RFID NFC Module:

PN532 RFID

PN532 RFID NFC Module with Arduino, how to use HSU UART, SPI, & I2C-in today’s tutorial, I am going to use the PN532 NFC RFID module with Arduino. Since this is a getting started article on the PN532 RFID module; so I will try my level best to explain as much as possible. I will also try to make this article as simple and easy to understand as possible. If you have any questions or suggestions, feel free to comment below. I will try to answer all your questions as soon as possible.




Anyway, I will also compare the PN532 RFID module with the most popular and well-known RFID module MFRC522. I will also try to explain the difference between PN532 and MFRC522. I will also share with you the technical specifications of PN532 so that you can decide which one is the right RFID module for you. And in the end,I will explain how to interface the PN532 RFID module with the Arduino and how to write basic programs to control an LED using different modes UART, I2C, and SPI. So, without any further delay let’s get started!!!

Amazon Links:

Arduino Nano

Arduino Uno

PN532 NFC RFID Module

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!



PN532 RFID Vs MFRC522 RFID Module:

PN532 RFID

First, let’s compare the PN532 RFID module with the most well-known MFRC522 RFID Module which I have been using for quite a long time.

MFRC522 RFID Module:

The MFRC522 RFID Module is a good choice if you’re looking for an inexpensive RFID reader module that supports the MIFARE® Classic 1k and 4k chips. You can read tags at up to 5m (16ft) with an active antenna and 10cm (3.9in) with a passive one. It has a high-speed SPI interface, which makes it easy to use in embedded applications. I have used it in so many projects “MFRC522 RFID Based Projects”.



PN532 RFID Module:

While on the other hand, the PN532 NFC RFID Module V3 is a very powerful and flexible RFID module. It can be used for many different applications such as access control, time attendance systems, animal identification, inventory management, and more.

It uses less power than the MFRC522 because its parts are designed for low-power consumption and it is also more flexible than the MFRC522. It has additional features such as support for a wider range of frequencies, making it easier to read tags from more angles without having to move your antenna around.

It is compatible with all ISO 14443 A and B standards, as well as the NXP’s MIFARE® Classic 1k and 4k chips. The PN532 has a high-speed SPI interface and is firmware upgradeable via an AT command set. It can read tags at up to 8m (27ft) with an active antenna and 10cm (3.9in) with a passive one. You can even use the PN532 in Linux or Mac OS X thanks to its open source drivers!

PN532 RFID

The PN532 also has an I2C interface, HSU “High Speed UART”, and SPI, which makes it easy to use in embedded applications. So, If you’re looking for a more advanced RFID reader module, the PN532 is a good choice.It can pretty much do it all, such as read and write to tags and cards, communicate with phones (say for payment processing), and ‘act’ like an NFC tag. If you want to do any sort of embedded NFC work, this is the chip you’ll want to use!



PN532 Technical Specifications:

It supports a Wide Range of input voltages from 2.7 to 3.6 volts. And this means it can be used with all 3.3V and 5V compatible controller boards like Arduino, ESP32, ESP8266, Raspberry Pi, Raspberry Pi Pico, STM32, and so on.In Active mode it uses 50mA at 13.56Mhz and 80mA at 125kHz.

While in sleep mode it uses only 1uA.

Now, let’s go ahead and take a look at its pinout.

  • Voltage: 2.7V to 5.5V DC
  • Current consumption (active): 50mA @ 13.56MHz, 80mA @ 125 kHz
  • Current consumption (sleep): 1uA
  • Operating frequency: 125KHz, 13.56MHz
  • Communication protocol: ISO 14443A/B, ISO 15693 (NFC Forum Type 2)
  • Antenna interface: U.FL connector or PCB trace antenna
  • RF output power: -13dBm (10 mW) @ 13.56MHz, -9dBm (1 mW) @ 125 kHz
  • Operating temperature range: -40°C to +85°C
  • Typical operating distance in Reader/Writer mode for communication to ISO/IEC 14443A/MIFARE®, ISO/IEC 14443B or FeliCa cards up to 50 mm depending on antenna size and tuning.
  • operating distance in NFCIP-1 mode up to 50 mm depending on antenna size, tuning and power supply
  • Typical operating distance in ISO/IEC 14443A/MIFARE or FeliCa card emulation mode of approximately 100 mm depending on antenna size, tuning and external field strength
  • Supports MIFARE Classic® 1K or MIFARE Classic 4K encryption in Reader/Writer mode and MIFARE higher transfer speed communication at 212 kbit/s and 424 kbit/s
  • Supports contactless communication according to the FeliCa protocol at 212 kbit/s and 424 kbit/s
  • Integrated RF interface for NFCIP-1 up to 424 kbit/s
  • Possibility to communicate on the RF interface above 424 kbit/s using external analog components
  • Supported host interfaces
    • SPI interface
    • I²C interface
    • High-speed UART
  • Low power modes
  • Dedicated host interrupts
  • Hard-Power-Down mode (1 µA typical)
  • Soft-Power-Down mode (22 µA typical)
  • Automatic wake-up on I²C, HSU and SPI interfaces when device is in Power-down mode
  • Programmable timers
  • Crystal oscillator
  • Power switch for external secure companion chi
  • Dedicated IO ports for external device control
  • Integrated antenna detector for production test
  • ECMA 373 NFC-WI interface to connect an external secure IC

The PN532 uses about 50mA of current. To calculate the voltage drop over your antenna, you can use Ohm’s law: V = I × R Where “V” is voltage drop, “I” is current and “R” is resistance. So for example if you have a 1 meter long wire with a resistance of 0.3 ohms and it’s carrying 50mA of current then the voltage drop will be 0.15V (0.5mA x 0.3 ohms). The PN532 is a 3.3V device. It can draw up to 20mA of current at 3.6V and up to 50mA at 2.7-3.6V, which is sufficient for transmitting data from a few meters away (depending on the RFID tag).




Altium Designer + Altium 365 + Octopart:

Arduino LoRa Free SMS

Altium 365 lets you hold the fastest design reviews ever. Share your designs from anywhere and with anyone with a single click. it’s easy, leave a comment tagging your teammate and they’ll instantly receive an email with a link to the design. Anyone you invite can open the design using a web browser. Using the browser interface, you’re able to comment, markup, cross probe, inspect, and more. Comments are attached directly to the project, making them viewable within Altium designer as well as through the browser interface. Design, share, and manufacture, all in the same space with nothing extra to install or configure. Connect to the platform directly from Altium Designer without changing how you already design electronics. Altium 365 requires no additional licenses and comes included with your subscription plan.

Get real-time component insights as you design with Octopart built into Altium 365. Octopart is the fastest search engine for electronic parts and gives you the most up-to-date part data like specs, datasheets, cad models, and how much the part costs at different amounts etc. Right in the design environment so you can focus on your designs. Start with Altium Designer and Activate Altium 365. Search for electronic parts on Octopart.

PN532 RFID Module V3 Pinout:

PN532 RFID

You can see all the headers are clearly labeled. The PN532 NFC RFID Module V3 can be interfaced with the Arduino and other controller boards using HSU (High Speed UART), I2C, and SPI.

PN532 RFID

This board has an onboard level shifter, standard 5V TTL for I2C and UART, and 3.3V TTL SPI. Anyway, the I2C and HSU (High Speed UART) shares the same pins.

PN532 RFID

The HSU mode is configured as the default mode. But if you want to change the interface then you can use these toggle switches. Don’t worry I will explain how to use all the three modes. First I will start with its default mode HSU.



PN532 RFID UART Circuit Diagram:

PN532 RFID

The VCC and GND pins of the PN532 RFID module are connected with the Arduino 5V and GND pins. While the TX and RX pins are connected with the Arduino D2 and D3 pins.

Two LEDs are connected with the Arduino pins 5 and 6. These are the minimal connections that you will need to get started. If you want to externally power up your Arduino board then you can use this 5V regulated power supply based on the LM7805 Voltage regulator. Otherwise, you can use your laptop to power up the Arduino.

PN532 RFID

As usual, I am using my Arduino Nano development board. I have connected the LEDs and PN532 RFID module as per the circuit diagram.For the HSU High Speed UART, you don’t need to change the position of the toggle switches, as by default it’s set to UART Mode.

It doesn’t matter if you start with HSU, I2C, or SPI, first you will need to download all the required libraries.

Download PN532 RFID Module Library

Simply download the above WinRAR folder, extract it, and double-click to open the folder.

PN532 RFID

You can see inside this folder we have all the required libraries, so simply copy these folders and paste it into the Arduino libraries folder.



PN532 RFID UART Programming:

 

This code is written for the HSU Mode and you can see I am using pins 3 and 2. And the LEDs are connected with the Arduino Pins 5 and 6. You can also use this code to find the RFID Tags IDs. For this simply Open the Serial monitor and start scanning your RFID Tags.

PN532 RFID

In a similar way, I also found the UID of the card.

   String tagId1 = “57.11.182.176”;

   String tagId2= “250.95.153.26”;

Using these IDs in the programming you can control certain things, in my case I am going to control 2 LEDs. Anyway, I have already uploaded this program and let’s watch the PN532 RFID module HSU mode in action.

PN532 RFID

Now, using the RFID Key Chain Tag.

PN532 RFID

For the practical demonstration, watch video tutorial on my YouTube channel “Electronic Clinic”. Now, let’s go ahead and start with the I2C mode.



PN532 RFID I2C Circuit Diagram:

PN532 RFID

I have already explained that HSU and I2C shares the same pins. This time you can see, the SDA and SCL pins of the PN532 RFID module are connected with the Arduino A4 and A5 pins. While everything else remains exactly the same.

PN532 RFID

Now, you can see the SDA and SCL pins are connected with the Arduino A4 and A5 pins. Since this time I am using the I2C mode, so I have turned ON the channel 1.




PN532 RFID I2C Programming:

 

This time I included the I2C library. I have already uploaded this program and now let’s watch the PN532 RFID Module I2C mode in action.

PN532 RFID

I successfully controlled the two LEDs using the RFID Card and the RFID key chain tag.Now, let’s go ahead and start with the SPI mode.



PN532 RFID SPI Circuit Diagram:

PN532 RFID

If you want to use the SPI mode of the PN532 RFID module then you will need to connect SCK with the Arduino pin 13, MISO with pin 12, MOSI with pin 11, SS with Pin 10, RST0 with Pin 9 of the Arduino. While everything else remains exactly the same.I connected the PN532 RFID module SPI pins with the Arduino as per the circuit diagram.

PN532 RFID

Now, to activate the SPI mode on the PN532 RFID module you will need to turn OFF the channel 1 and turn ON the channel 2.

PN532 RFID SPI Programming:

 

This time you can see I have added the SPI library. Everything else remains exactly the same. I have already uploaded this program and now let’s watch PN532 RFID Module SPI mode in action.

PN532 RFID

I successfully controlled the two LEDs using RFID Key Chain Tag and the RFID Card tag. So, that’s all about how to use the PN532 NFC RFID module with the Arduino and how to use all the three interfaces or modes UART, I2C, and SPI.

In my upcoming tutorial, I will use the same PN532 RFID module with the Nodemcu ESP8266 and Google Spreadsheet. This will be a fun project, so subscribe to my Website and YouTube channel if you don’t want to miss any of my upcoming articles and videos.



Watch Video Tutorial:

 

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply

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

Back to top button