RAK13600 WisBlock NFC Reader Module Quick Start Guide
Prerequisite
- Assemble the RAK13600 with a WisBlock Base and WisBlock Core by following the RAK13600 Installation Guide.
- Download and install the Arduino IDE, then add the RAKwireless Core boards by installing the RAKwireless Arduino BSP.
- USB Cable
- Li-Ion/LiPo battery (optional)
- Solar charger (optional)
Software Configuration and Example
The RAK13600 is based on the popular NFC/RFID chip PN532. You need to install the RAK13600-PN532 library to use the module. By default, the module communicates via I2C to the WisBlock Core module. The following guide shows how to test your RAK13600 module using a standard RFID card.
Figure 1: RAK13600 with Coil and RFID Card- This guide uses the RAK4631 WisBlock Core to demonstrate the configuration and upload process. The example is also compatible with other WisBlock Cores, including the RAK11200 and RAK11310.
- When using RAK11200 as WisBlock Core, configure the BOOT0 pin properly before uploading the firmware. Incorrect BOOT0 configuration may cause the firmware upload to fail. For more information, refer to the RAK11200 Quick Start Guide.
- Open the Arduino IDE and select the WisBlock Core you use.
Figure 1: Selecting RAK4631 as WisBlock Core- Copy the example code below and paste it on the Arduino IDE:
Click to view the example
/**
@file readMifareClassic.ino
@author rakwireless.com
@brief This example will wait for any ISO14443A card or tag, and depending on the size of the UID will attempt to read from it.
@version 0.1
@date 2021-10-14
@copyright Copyright (c) 2021
**/
#include <Wire.h>
#include <SPI.h>
#include <RAK13600-PN532.h> // Click here to get the library: http://librarymanager/All#RAK13600-PN532
// If using the breakout or shield with I2C, define just the pins connected
#define PN532_IRQ (WB_IO6)
#define PN532_RESET (WB_IO5) // Not connected by default on the NFC Shield
// Or use this line for a breakout or shield with an I2C connection:
NFC_PN532 nfc(PN532_IRQ, PN532_RESET);
void setup(void) {
Serial.begin(115200);
pinMode(WB_IO2, OUTPUT);
digitalWrite(WB_IO2, HIGH);
delay(300);
while (!Serial) delay(10); // for Leonardo/Micro/Zero
Serial.println("Hello!");
nfc.begin();
uint32_t versiondata = nfc.getFirmwareVersion();
if (! versiondata) {
Serial.print("Didn't find PN53x board");
while (1); // halt
}
// 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);
// configure board to read RFID tags
nfc.SAMConfig();
Serial.println("Waiting for an ISO14443A Card ...");
}
void loop(void) {
uint8_t success;
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)
// Wait for an ISO14443A type cards (Mifare, etc.). When one is found
// 'uid' will be populated with the UID, and uidLength will indicate
// if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
if (success) {
// Display some basic information about the card
Serial.println("Found an ISO14443A card");
Serial.print(" UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
Serial.print(" UID Value: ");
nfc.PrintHex(uid, uidLength);
if (uidLength == 4)
{
// We probably have a Mifare Classic card ...
uint32_t cardid = uid[0];
cardid <<= 8;
cardid |= uid[1];
cardid <<= 8;
cardid |= uid[2];
cardid <<= 8;
cardid |= uid[3];
Serial.print("Seems to be a Mifare Classic card #");
Serial.println(cardid);
}
Serial.println("");
}
delay(2000);
}
- Install the RAK13600-PN532 library by clicking the link highlighted by red box.
Figure 1: Getting the RAK13600-PN532 Library- You will be directed to the Library Manager then you have to click install.
Figure 1: Installing RAK13600-PN532 Library- Next, you need to install an additional library from Adafruit. You need to type on the library search box
adafruit busiothen install it by clicking install. After the successful installation of the two libraries, you can now close the Library Manager window.
Figure 1: Installing Adafruit BusIO Library- Select the right Serial Port and upload the code.
Figure 1: Selecting the correct Serial Port
Figure 1: Uploading the sample codeIf you experience any error in compiling the demo sketch, check the updated code for the RAK13600 readMifareClassic example. Other example codes for RAK13600 are also available on the RAK13600 WisBlock Example Code Repository.
- When you have successfully uploaded the example code, open the serial monitor by clicking the magnifying glass icon on the upper right of the Arduino IDE then place the RFID card on top of the antenna coil. You should see the details of the card.
Figure 1: RFID Card Information Read by the RAK13600