NFC (Near-field communication) is a protocol that enable 2 devices to communicate typically smart phone device and NFC tags / devices to establish communication by getting them together range of 4 cm at 1.6 inch defends of usage and antenna circuitry. NFC device are used in contactless payment system, security, marketing, transportations, Bluetooth fairing. Etc. NFC also can be found on your mobile phones that can act as electronic identity documents and keycards working on a low speed connection.


Each NFC device can work in 3 modes, can be NFC Card Emulation it means that NFC device such as smart phones can act as smart cards allowing the smart phones to transact as payment or ticketing. NFC devices also allows you two write / read information stored on NFC tags in embedded in labels, tickers, passports or smart posters. NFC PTP (Pear to Pear) allows you to NFC enabled devices to communicate with each other devices to exchange information.

The diagram below demonstrate how to used NFC devices with your microcontrollers. As you can see the diagram below there are two options the first option is wired using i2C (2 Wire Communication), second option is wired using SPI (Serial Peripheral Interface) below are the component required for this test.

Required Components

  • Arduino Microcontroller, ESP8266 12, 12E, ESP8266 NodeMCU, ESPDuino, ATMEGA328 16/12, ATMEGA32u4 16/8/ MHz, ESP8266, ATMEGA250 16 MHz, ATSAM3x8E, ATSAM21D, ATTINY85 16/8 MHz (Note: The Diagram below is using NANO. (please refer to the respective pin-outs)
  • NFC Module / NFC Shield / NFC MCU Integrated
  • Solder Less Bread Board
  • Jumper Wires / DuPont Wires

Wiring Guide

When you save and upload the code below unto your MCU w/d the module/shield attached you can now begin testing and show the message burn-in your tags, when you upload the code into the MCU then opening the serial monitor you will see the message 14CORE | NFC – i2C Test Code TAG Reader see below code to write data into your TAGS to read from your smart phone.

Source Code for i2C

Source Code for SPI

Writing on NFC Tag Source Code

Downloads

  • Download PN532 Code Library | Zip
  • Download PN532 NFC Shield | Zip
  • Download Adafruit PN532 Code Library | Zip
  • Download PN532 Datasheet | PDF
  • Download PN532 HSU | PN532 I2C | PN532 SPI
Wiring the PN532 (NFC) Near Field Communication Devices with Microcontroller
Facebooktwitterredditpinterestmail
Tagged on:         

JLCPCBPCBgogoPCBway4pcb

3 thoughts on “Wiring the PN532 (NFC) Near Field Communication Devices with Microcontroller

  • at
    Permalink

    Hi, I need help.
    Fail to compile “Source Code for i2C” and “Writing on NFC Tag Source Code”.
    Cannot identify nfc.tagPresent() in the programs.
    I wonder what is missing in the header portion #include ??????
    I’m using Arduino UNO and my PC.
    I appreciate your reply.

    Reply
    • at
      Permalink

      check if you include all required libraries, nfc.tagPresent()

      #include PN532_I2C.h #include PN532.h #include NfcAdapter.h

      Reply
  • at
    Permalink

    Hi,
    Just let me know how to compile above programs without errors.
    I’m using Arduino uno.and PN532 reader/writer or RFID reaer/writer.and failed to compile
    I copied the program to sketch , but failed to compile, hence no upload.
    The nfc.tagPresent() and NfcTag tag = nfc.read() are undefined.
    Please tell me what is missing in the header portion.
    Thank for your help.

    Reply

Leave a Reply

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