HOW TO USE THE CPX WITH A RFID-RC522 MODULE?

Play with it! Please tell us which board you're using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
luisalazago
 
Posts: 4
Joined: Mon Oct 18, 2021 1:28 am

HOW TO USE THE CPX WITH A RFID-RC522 MODULE?

Post by luisalazago »

Greetings people,

I have issues trying to use a CPX with an RFID-RC522 module. I am using an Arduino code, no python, and the problem is that the RFID module is not reading a card, and I am using a card made for the RFID module. Specifically the card is not read by the CPX and I don't know what is the problem.

To have more details I am going to insert my code, thank you and have a good day.

Code: Select all

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

using namespace std;

#define RST_PIN A4 // Reset
#define SS_PIN A5 //SS (SDA) of RC522
MFRC522 mfrc522(A5, A4); //Object to RC522

void setup() {
  CircuitPlayground.begin();
  Serial.begin(9600);
  SPI.begin();
  mfrc522.PCD_Init();
}

int j = 0;

void loop() {
  // Check the new cards
  if(!mfrc522.PICC_IsNewCardPresent()) {
    Serial.print("Bye\n");
    return;
  }
  if (!mfrc522.PICC_ReadCardSerial()) {
    Serial.print("Bye2\n");
    return;
  }
  //Show UID on serial monitor
  Serial.print("UID tag :");
  String content= "";
  byte letter;
  for (byte i = 0; i < mfrc522.uid.size; i++) 
  {
     Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
     Serial.print(mfrc522.uid.uidByte[i], HEX);
     content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
     content.concat(String(mfrc522.uid.uidByte[i], HEX));
  }
  Serial.println();
}

User avatar
raldi
 
Posts: 25
Joined: Fri Mar 03, 2017 3:22 am

Re: HOW TO USE THE CPX WITH A RFID-RC522 MODULE?

Post by raldi »

How did you connect the pins between the CPX and RFID module? Getting SPI to work on the CPX is tricky; you might want to follow along with my post at viewtopic.php?f=58&t=184804 and see if together we can get to an answer.

User avatar
raldi
 
Posts: 25
Joined: Fri Mar 03, 2017 3:22 am

Re: HOW TO USE THE CPX WITH A RFID-RC522 MODULE?

Post by raldi »

Note that on the CPX, A4 is also D3, and A5 is D2. Try changing "A4" to "3" and "A5" to "2" in your code and see if that gets things going.

Locked
Please be positive and constructive with your questions and comments.

Return to “Circuit Playground Classic, Circuit Playground Express, Circuit Playground Bluefruit”