Difference between revisions of "Ks0259 keyestudio PN532 NFC/RFID Controller Shield"

From Keyestudio Wiki
Jump to: navigation, search
(Created page with "==keyestudio 16-channel Servo Motor Drive Shield== <br>500px|frameless|thumb<br> ==Introduction== This is a GPRS / GSM Arduino expansion boarddeveloped by...")
 
(Resources)
 
(27 intermediate revisions by the same user not shown)
Line 1: Line 1:
==keyestudio 16-channel Servo Motor Drive Shield==
 
<br>[[File:KS0258.png|500px|frameless|thumb]]<br>
 
  
 +
 +
[[image:KS0259.png|thumb|800px|right|keyestudio PN532 NFC/RFID Controller Shield]]
 +
 +
 +
<br>
 
==Introduction==
 
==Introduction==
This is a GPRS / GSM Arduino expansion boarddeveloped by Keyes. It is a shield module with frequency of EGSM 900MHz / DCS 1800MHz and GSM850 MHz / PCS 1900MHz, integrated with GPRS, DTMF and other functions. It supports DTMF, when the DTMF function is enabled, you can get the character feedback from the conversion of button pressed down during the call, which can be used for remote control.<br>
+
Keyestudio PN532 NFC/RFID Controller Shield based on PN532 chip is used for field communication close to 13.56MHz. This shield is equipped with an antenna onboard, so there is no external antenna coil. It is compatible with SPI, IIC, UART interface to communicate. When using it, directly stack it onto UNO R3 control board.
It is controlled by the AT command, you can directlystart its function through the computer serial port and Arduino motherboard. The SIM800C GPRS Shield board has abuilt-in SIM800H chip with good stability.<br>
+
 
 +
<br>
 +
==Specifications==
 +
*Chip:NXP PN532
 +
*Working Voltage:3.3V
 +
*Power Voltage:3.3~5.5V
 +
*Max Power Current:150mA
 +
*Working Current (standby mode): 100 mA
 +
*Working Current (write mode): 120 mA
 +
*Working Current (read mode): 120 mA
 +
*Pointer: PWR
 +
*The longest effective communication distance is 2.4 cm
 +
*Support SPI, IIC, UART interface switching.
 +
*Can be used for 13.56M non-contact communication.
 +
*Compatible with ISO14443 TYPE A and B standard.
 +
 
 +
<br>
 +
 
 +
==Details==
 +
*'''Dimensions:''' 69mm x 54mm x 24mm
 +
*'''Weight:''' 18.3g
 +
<br>[[File:Ks0259 - size.png|600px|frameless|thumb]]<br>
 +
 
 +
<br>
 +
== Interface Explanation  ==
 +
<br>[[File:KS0259 PINOUT.jpg|800px|frameless|thumb]]<br>
 +
 
 +
<br>
 +
== Interface Control ==
 +
There are two slide switches on the shield for you to select the interface mode:
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
!
 +
!SET0
 +
!SET1
 +
|-
 +
|UART
 +
|L
 +
|L
 +
|-
 +
|SPI
 +
|L
 +
|H
 +
|-
 +
|IIC
 +
|H
 +
|L
 +
|-
 +
|}
 +
 
 +
 
 +
<br>
 +
 
 +
== Simple Hookup==
 +
Simply stack the shield onto [http://wiki.keyestudio.com/index.php/Ks0001_keyestudio_UNO_R3_BOARD  UNO R3 board ]. <br>
 +
It uses SPI communication. Connect SCK, MI, MO and NSS on the shield with jumper cap. Then slide SET0 to L, SET1 to H.
 +
<br>[[File:KS0259-2.png|700px|frameless|thumb]]<br>
 +
 
 +
<br>
 +
== Sample Code ==
 +
*Copy and paste the code below to [http://wiki.keyestudio.com/index.php/How_to_Download_Arduino_IDE  Arduino IDE ]. <br>
 +
*Or [https://drive.google.com/open?id=1_iMEuSfUs63LtBlmL5ZnWWNIwk95Yyns  click here ]to download the code. <br> 
 +
*[https://drive.google.com/open?id=1sP1TKdzJ1Ia_kCsPey7d7aFXGOIj8F2q  Click here] to download the libraries ''PN532.h and SPI.h''
 +
 
 +
'''Note:''' Before compile the code, do remember to add the libraries inside the libraries folder of Arduino IDE.
 +
<pre>
 +
//This example reads a MIFARE memory block. It is tested with a new MIFARE 1K cards. Uses default keys.
 +
//Contributed by Seeed Technology Inc (www.seeedstudio.com)
 +
 
 +
#include <PN532.h>
 +
#include <SPI.h>
 +
 
 +
/*Chip select pin can be connected to D10 or D9 which is hareware optional*/
 +
/*if you the version of NFC Shield from SeeedStudio is v2.0.*/
 +
#define PN532_CS 10
 +
 
 +
PN532 nfc(PN532_CS);
 +
#define  NFC_DEMO_DEBUG 1
 +
 
 +
void setup(void) {
 +
#ifdef NFC_DEMO_DEBUG
 +
  Serial.begin(9600);
 +
  Serial.println("Hello!");
 +
#endif
 +
  nfc.begin();
 +
 
 +
  uint32_t versiondata = nfc.getFirmwareVersion();
 +
  if (! versiondata) {
 +
#ifdef NFC_DEMO_DEBUG
 +
    Serial.print("Didn't find PN53x board");
 +
#endif
 +
    while (1); // halt
 +
  }
 +
#ifdef NFC_DEMO_DEBUG
 +
  // Got ok data, print it out!
 +
  Serial.print("Found chip PN5");
 +
  Serial.println((versiondata>>24) & 0xFF, HEX);
 +
  Serial.print("Firmware ver. ");
 +
  Serial.print((versiondata>>16) & 0xFF, DEC);
 +
  Serial.print('.');
 +
  Serial.println((versiondata>>8) & 0xFF, DEC);
 +
  Serial.print("Supports ");
 +
  Serial.println(versiondata & 0xFF, HEX);
 +
#endif
 +
  // configure board to read RFID tags and cards
 +
  nfc.SAMConfig();
 +
}
 +
 
 +
void loop(void) {
 +
  uint32_t id;
 +
  // look for MiFare type cards
 +
  id = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A);
 +
 
 +
  if (id != 0)
 +
  {
 +
#ifdef NFC_DEMO_DEBUG
 +
    Serial.print("Read card #");
 +
    Serial.println(id);
 +
#endif 
 +
    uint8_t keys[]= { 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF };
 +
    if(nfc.authenticateBlock(1, id ,0x08,KEY_A,keys)) //authenticate block 0x08
 +
    {
 +
      //if authentication successful
 +
      uint8_t block[16];
 +
      //read memory block 0x08
 +
      if(nfc.readMemoryBlock(1,0x08,block))
 +
      {
 +
#ifdef NFC_DEMO_DEBUG
 +
        //if read operation is successful
 +
        for(uint8_t i=0;i<16;i++)
 +
        {
 +
          //print memory block
 +
          Serial.print(block[i],HEX);
 +
          Serial.print(" ");
 +
        }
 +
        Serial.println();
 +
#endif
 +
      }
 +
    }
 +
  }
 +
delay(500);
 +
}
 +
</pre>
 +
 
 +
'''Note:''' Before compile the code above, do remember to add the libraries inside the libraries folder of Arduino IDE.
 +
<br>[[File:KS0259 - libraries.png|600px|frameless|thumb]]<br>
  
==Specification==
 
  
 +
<br>
 +
 +
== Test Result ==
 +
Done uploading the above code, open the serial monitor.
 +
<br>[[File:Ks0259- upload.png|600px|frameless|thumb]]<br>
 +
<br>[[File:Ks0259- monitor 1.png|600px|frameless|thumb]]<br>
 +
 +
<br>
 +
Then respectively use S50 white card and key chain to test the shield, you will get the information shown below.
 +
<br>[[File:KS0259-3.png|600px|frameless|thumb]]<br>
 +
 +
 +
<br>
 
==Resources ==
 
==Resources ==
  
'''Datasheet'''<br>
+
'''Download the code and libraries:'''<br>
PDF <br>
 
  
 +
https://fs.keyestudio.com/KS0259
 +
 +
<br>
  
 
==Get One Now ==
 
==Get One Now ==
 +
*[https://www.keyestudio.com/keyestudio-pn532-nfc-rfid-controller-shield-for-arduino-uno-r3-p0147.html  '''Official Website''' ]
 +
 +
*[https://www.amazon.com/KEYESTUDIO-PN532-Controller-Shield-Arduino/dp/B0797J7M6P  '''Shop on Amazon''']
 +
 +
*[https://www.ebay.com/itm/Keyestudio-PN532-NFC-RFID-IC-Card-Reader-Module-13-56MHz-for-Arduino-UNO-R3/132514819532?hash=item1eda7fadcc:g:npUAAOSwC-JbLj8i    '''Shop on eBay''']
 +
 +
*[https://www.aliexpress.com/store/product/Keyestudio-PN532-NFC-RFID-Controller-Shield-for-arduino-uno-r3/1452162_32832270205.html?spm=2114.12010612.8148356.60.1e99276fKkye4P  '''Shop on Aliexpress''']
  
  
  
[[Category: shield]]
+
[[Category: Shield]]

Latest revision as of 06:24, 6 January 2021


keyestudio PN532 NFC/RFID Controller Shield



Introduction

Keyestudio PN532 NFC/RFID Controller Shield based on PN532 chip is used for field communication close to 13.56MHz. This shield is equipped with an antenna onboard, so there is no external antenna coil. It is compatible with SPI, IIC, UART interface to communicate. When using it, directly stack it onto UNO R3 control board.


Specifications

  • Chip:NXP PN532
  • Working Voltage:3.3V
  • Power Voltage:3.3~5.5V
  • Max Power Current:150mA
  • Working Current (standby mode): 100 mA
  • Working Current (write mode): 120 mA
  • Working Current (read mode): 120 mA
  • Pointer: PWR
  • The longest effective communication distance is 2.4 cm
  • Support SPI, IIC, UART interface switching.
  • Can be used for 13.56M non-contact communication.
  • Compatible with ISO14443 TYPE A and B standard.


Details

  • Dimensions: 69mm x 54mm x 24mm
  • Weight: 18.3g


thumb


Interface Explanation


thumb


Interface Control

There are two slide switches on the shield for you to select the interface mode:

SET0 SET1
UART L L
SPI L H
IIC H L



Simple Hookup

Simply stack the shield onto UNO R3 board .
It uses SPI communication. Connect SCK, MI, MO and NSS on the shield with jumper cap. Then slide SET0 to L, SET1 to H.
thumb


Sample Code

Note: Before compile the code, do remember to add the libraries inside the libraries folder of Arduino IDE.

//This example reads a MIFARE memory block. It is tested with a new MIFARE 1K cards. Uses default keys.
//Contributed by Seeed Technology Inc (www.seeedstudio.com)

#include <PN532.h>
#include <SPI.h>

/*Chip select pin can be connected to D10 or D9 which is hareware optional*/
/*if you the version of NFC Shield from SeeedStudio is v2.0.*/
#define PN532_CS 10

PN532 nfc(PN532_CS);
#define  NFC_DEMO_DEBUG 1

void setup(void) {
#ifdef NFC_DEMO_DEBUG
  Serial.begin(9600);
  Serial.println("Hello!");
#endif
  nfc.begin();

  uint32_t versiondata = nfc.getFirmwareVersion();
  if (! versiondata) {
#ifdef NFC_DEMO_DEBUG
    Serial.print("Didn't find PN53x board");
#endif
    while (1); // halt
  }
#ifdef NFC_DEMO_DEBUG
  // Got ok data, print it out!
  Serial.print("Found chip PN5"); 
  Serial.println((versiondata>>24) & 0xFF, HEX);
  Serial.print("Firmware ver. "); 
  Serial.print((versiondata>>16) & 0xFF, DEC);
  Serial.print('.'); 
  Serial.println((versiondata>>8) & 0xFF, DEC);
  Serial.print("Supports "); 
  Serial.println(versiondata & 0xFF, HEX);
#endif
  // configure board to read RFID tags and cards
  nfc.SAMConfig();
}

void loop(void) {
  uint32_t id;
  // look for MiFare type cards
  id = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A);

  if (id != 0) 
  {
#ifdef NFC_DEMO_DEBUG
    Serial.print("Read card #"); 
    Serial.println(id);
#endif  
    uint8_t keys[]= { 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF };
    if(nfc.authenticateBlock(1, id ,0x08,KEY_A,keys)) //authenticate block 0x08
    {
      //if authentication successful
      uint8_t block[16];
      //read memory block 0x08
      if(nfc.readMemoryBlock(1,0x08,block))
      {
#ifdef NFC_DEMO_DEBUG
        //if read operation is successful
        for(uint8_t i=0;i<16;i++)
        {
          //print memory block
          Serial.print(block[i],HEX);
          Serial.print(" ");
        }
        Serial.println();
#endif
      }
    }
  }
 delay(500);
}

Note: Before compile the code above, do remember to add the libraries inside the libraries folder of Arduino IDE.
thumb



Test Result

Done uploading the above code, open the serial monitor.
thumb

thumb


Then respectively use S50 white card and key chain to test the shield, you will get the information shown below.
thumb



Resources

Download the code and libraries:

https://fs.keyestudio.com/KS0259


Get One Now