Piico RFID module on Arduino Nano 33

Hi, I wish to implement (subject) using GPIO pins of the MCU board. Online tutorials have simply used expansion boards and Piicodev cables on RPi Pico specifically.

Any help in this direction would be great, thanks!

Regards,
PC

2 Likes

Hi Prithul,

What programming language were you looking to use?
If you are using micropython they you should be able to use the examples we provide - just make sure to change the pin numbers (all of the programming documentation can be found in the GitHub, linked from the product page).

If you want to use Arduino, you’ll have to find a library for the MFRC522 on the module.

Best of luck and let us know if you need a hand with anything else!
Liam

2 Likes

Hi Liam, thanks for the quick response!

I am planning to use Arduino for now so I have been following MFRC522 examples. However, the board seems to not respond:
image

Though I am not entirely sure, my connections are as follows [RFID module to Nano 33]:
RST - D9
INT - D10
SCL - A5
SDA - A4
3.3V - 3.3V
GND - GND

Regards,
PC

1 Like

Hey @Prithul271176,

Your pin connections seem sound at first glance. Any chance you could send a link to the MFRC522 library you used, as well as the code you’re uploading to the Arduino? There are a couple of things we can check once you’re sent those through.

If we can’t find the issue, I’ll see about getting it set up on my end to test.

2 Likes

Hi
Looking at the Arduino layout maybe SDA should be A4.
Cheers Bob

2 Likes

Hey @Robert93820,

Thanks for catching that one, not quite sure how I missed it, lol.

2 Likes

My bad, was a typo. Just double checked, it’s A4.

Good eye :slight_smile:

2 Likes

Hey Zach, sure!

I am using this library: GitHub - miguelbalboa/rfid: Arduino RFID Library for MFRC522

My code is plainly based out of the example program with the package called DumpInfo.ino:

/*
 * --------------------------------------------------------------------------------------------------------------------
 * Example sketch/program showing how to read data from a PICC to serial.
 * --------------------------------------------------------------------------------------------------------------------
 * This is a MFRC522 library example; for further details and other examples see: https://github.com/miguelbalboa/rfid
 * 
 * Example sketch/program showing how to read data from a PICC (that is: a RFID Tag or Card) using a MFRC522 based RFID
 * Reader on the Arduino SPI interface.
 * 
 * When the Arduino and the MFRC522 module are connected (see the pin layout below), load this sketch into Arduino IDE
 * then verify/compile and upload it. To see the output: use Tools, Serial Monitor of the IDE (hit Ctrl+Shft+M). When
 * you present a PICC (that is: a RFID Tag or Card) at reading distance of the MFRC522 Reader/PCD, the serial output
 * will show the ID/UID, type and any data blocks it can read. Note: you may see "Timeout in communication" messages
 * when removing the PICC from reading distance too early.
 * 
 * If your reader supports it, this sketch/program will read all the PICCs presented (that is: multiple tag reading).
 * So if you stack two or more PICCs on top of each other and present them to the reader, it will first output all
 * details of the first and then the next PICC. Note that this may take some time as all data blocks are dumped, so
 * keep the PICCs at reading distance until complete.
 * 
 * @license Released into the public domain.
 * 
 * Typical pin layout used:
 * -----------------------------------------------------------------------------------------
 *             MFRC522      Arduino       Arduino   Arduino    Arduino          Arduino
 *             Reader/PCD   Uno/101       Mega      Nano v3    Leonardo/Micro   Pro Micro
 * Signal      Pin          Pin           Pin       Pin        Pin              Pin
 * -----------------------------------------------------------------------------------------
 * RST/Reset   RST          9             5         D9         RESET/ICSP-5     RST
 * SPI SS      SDA(SS)      10            53        D10        10               10
 * SPI MOSI    MOSI         11 / ICSP-4   51        D11        ICSP-4           16
 * SPI MISO    MISO         12 / ICSP-1   50        D12        ICSP-1           14
 * SPI SCK     SCK          13 / ICSP-3   52        D13        ICSP-3           15
 *
 * More pin layouts for other boards can be found here: https://github.com/miguelbalboa/rfid#pin-layout
 */

#include <SPI.h>
#include <MFRC522.h>

#define RST_PIN         D9          // Configurable, see typical pin layout above
#define SS_PIN          A4         // Configurable, see typical pin layout above

MFRC522 mfrc522(SS_PIN, RST_PIN);  // Create MFRC522 instance

void setup() {
	Serial.begin(9600);		// Initialize serial communications with the PC
	while (!Serial);		// Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
	SPI.begin();			// Init SPI bus
	mfrc522.PCD_Init();		// Init MFRC522
	delay(4);				// Optional delay. Some board do need more time after init to be ready, see Readme
	mfrc522.PCD_DumpVersionToSerial();	// Show details of PCD - MFRC522 Card Reader details
	Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));
}

void loop() {
	// Reset the loop if no new card present on the sensor/reader. This saves the entire process when idle.
	if ( ! mfrc522.PICC_IsNewCardPresent()) {
		return;
	}

	// Select one of the cards
	if ( ! mfrc522.PICC_ReadCardSerial()) {
		return;
	}

	// Dump debug info about the card; PICC_HaltA() is automatically called
	mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
}

I haven’t understood what INT means, and I don’t see where I should be passing that information in the code. This is what I really need help with also basically.

Regards,
PC

1 Like

Hi @Prithul271176,

I think I can see your first hurdle. The Piicodev RFID reader is an I2C device, not an SPI device. That library is trying to initialise the device as an SPI device.

I’m not sure how much work would go into making this library work but odds are you can find another that will work without many hiccups.

3 Likes

Hi Jack, thanks for that! I’ll try looking for an alternate library now. If you come across something, I’d really appreciate your efforts and help :slight_smile:

Regards,
PC

1 Like

Hi @Prithul271176,

I had a look at some libraries yesterday. Some claim they are for I2C but in their GitHub they say I2C isn’t working :man_shrugging:

This is the only one I found that mentions it works with I2C but I haven’t tested it yet.

2 Likes

Hi Aaron, thanks for the input. Let me have a look and get back to you!

PC

3 Likes

I am working on using GitHub - kkloesener/MFRC522_I2C on an Arduino Uno, but I still don’t understand what INT is on the Piico RFID reader board.

Can someone please guide me here?

The example program for the said library does not initialise anything as such:

#define RST_PIN 6 // Arduino UNO
// #define RST_PIN 14 // D5 on NodeMCU

// 0x28 is i2c address of the NFC Reader. Check your address with i2cscanner if not match.
MFRC522_I2C mfrc522(0x28, RST_PIN);   // Create MFRC522 instance.

EDIT: Surprisingly, I cannot find anything re this application on even a RPi without the Piicodev adapter.

PC

1 Like

Hi @Prithul271176,

The Datasheet and the Schematic from the Hardware repo will be helpful in understanding more about the board.

The pin allows the MFCR522 chip to send a signal to interrupt the host. From what I can tell it isn’t explicitly needed for running this chip in general but can be helpful for streamlining software using this chip.

3 Likes

Hi Aaron, thanks for that!

I am testing this piece of code picked from MFRC_I2C_Library, but it fails to detect the RFID reader.

#include <Wire.h>

#include "MFRC522_I2C.h"

#define SDA_PIN 18
#define SCL_PIN 19
#define RST_PIN 7

MFRC522 mfrc522(0x28, RST_PIN);	// Create MFRC522 instance.

void ShowReaderDetails();

void setup() {
	Serial.begin(9600);	// Initialize serial communications with the PC
	Wire.begin(); // Initialize I2C
	mfrc522.PCD_Init();		// Init MFRC522
	ShowReaderDetails();	// Show details of PCD - MFRC522 Card Reader details
	Serial.println(F("Scan PICC to see UID, type, and data blocks..."));
}

void loop() {
	// Look for new cards
	if ( ! mfrc522.PICC_IsNewCardPresent()) {
		return;
	}

	// Select one of the cards
	if ( ! mfrc522.PICC_ReadCardSerial()) {
		return;
	}

	// Dump debug info about the card; PICC_HaltA() is automatically called
	mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
}

void ShowReaderDetails() {
	// Get the MFRC522 software version
	byte v = mfrc522.PCD_ReadRegister(mfrc522.VersionReg);
	Serial.print(F("MFRC522 Software Version: 0x"));
	Serial.print(v, HEX);
	if (v == 0x91)
		Serial.print(F(" = v1.0"));
	else if (v == 0x92)
		Serial.print(F(" = v2.0"));
	else
		Serial.print(F(" (unknown)"));
	Serial.println("");
	// When 0x00 or 0xFF is returned, communication probably failed
	if ((v == 0x00) || (v == 0xFF)) {
		Serial.println(F("WARNING: Communication failure, is the MFRC522 properly connected?"));
	}
}

UPDATE: I have double checked my wires to ensure they’re all working.
PC

1 Like

Hi all,

I found the bug, I was using the wrong I2C address! I found the correct one using the method here. The following sketch works when my RST is D7 on my Arduino Uno:

#include <Wire.h>
#include "MFRC522_I2C.h"

#define RST_PIN 7

// MFRC522 instance.
MFRC522 mfrc522(0x2C, RST_PIN);

void setup() {
  Serial.begin(115200);           // Initialize serial communications with the PC
  Wire.begin();                   // Initialize I2C
  mfrc522.PCD_Init();             // Init MFRC522
  ShowReaderDetails();            // Show details of PCD - MFRC522 Card Reader details
  Serial.println(F("Scan PICC to see UID, type, and data blocks..."));
}

void loop() {
  // Look for new cards, and select one if present
  if ( ! mfrc522.PICC_IsNewCardPresent() || ! mfrc522.PICC_ReadCardSerial() ) {
    delay(50);
    return;
  }
  
  // Now a card is selected. The UID and SAK is in mfrc522.uid.
  
  // Dump UID
  Serial.print(F("Card UID:"));
  for (byte i = 0; i < mfrc522.uid.size; i++) {
    Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
    Serial.print(mfrc522.uid.uidByte[i], HEX);
  } 
  Serial.println();
}

void ShowReaderDetails() {
  // Get the MFRC522 software version
  byte v = mfrc522.PCD_ReadRegister(mfrc522.VersionReg);
  Serial.print(F("MFRC522 Software Version: 0x"));
  Serial.print(v, HEX);
  if (v == 0x91)
    Serial.print(F(" = v1.0"));
  else if (v == 0x92)
    Serial.print(F(" = v2.0"));
  else
    Serial.print(F(" (unknown)"));
  Serial.println("");
  // When 0x00 or 0xFF is returned, communication probably failed
  if ((v == 0x00) || (v == 0xFF)) {
    Serial.println(F("WARNING: Communication failure, is the MFRC522 properly connected?"));
  }
}

Thanks for your patience and support!

PC

2 Likes

Good to hear @Prithul271176!

Those I2C addresses can be an easy thing to overlook especially if you’re working with new libraries.

Best of luck with this project!

1 Like