RFID reader question

This is a special forum devoted to educators using Adafruit and Arduino products for teaching.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
FutureEngineer
 
Posts: 59
Joined: Sat Dec 26, 2015 5:11 pm

RFID reader question

Post by FutureEngineer »

Good morning,

I am working on a project that uses an Adafruit RFID reader with an Arduino UNO. When I test readMifareClassic from the Adafruit PN532 library, it works, and it displays the address of the card. However, when I used the same code in an Arduino sketch, the reader did not identify the cards. I attached an image that shows the result.

The code is added below. Can you assist, please?

Code: Select all

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_PN532.h>
#define PN532_IRQ   (2)
#define PN532_RESET (3)  // Not connected by default on the NFC Shield
Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);


void setup(void) {
  Serial.begin(9600);
  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);
  nfc.SAMConfig();
  Serial.println("Waiting for an ISO14443A Card ...");
  

   
}


void loop() {  
  

  
  
   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)
   success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
  
  if (success) {
    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);     
    Serial.println("");
   
          
  /////// Use the address information to save the crediet value 
   if( uid[0]==12 && uid[1]==209 && uid[2]==114 && uid[3]==59 ) 
     { 
       Serial.println("Card #1: Ahmed ");
     }
    
    if( uid[0]==164 && uid[1]==61 && uid[2]==78 && uid[3]==18 ) 
      { 
        Serial.println("Card #2: Latifa ");
        
      }
     
     if( uid[0]==131 && uid[1]==130 && uid[2]==27 && uid[3]==188 ) 
       { 
         Serial.println("Card #3: Amna ");
       }
    
      if( uid[0]==243 && uid[1]==102 && uid[2]==29 && uid[3]==188 ) 
       { 
         Serial.println("Card #4: Mayasa ");
         
       }
    
      if( uid[0]==51 && uid[1]==13 && uid[2]==26 && uid[3]==188 ) 
        { 
          Serial.println("Card #5: Sara ");
 
        }
    
       if( uid[0]==3 && uid[1]==194 && uid[2]==27 && uid[3]==188 ) 
         { 
           Serial.println("Card #6: Omer ");
        }
    

}







Attachments
RFID_Library.png
RFID_Library.png (94.3 KiB) Viewed 65 times

User avatar
Franklin97355
 
Posts: 24414
Joined: Mon Apr 21, 2008 2:33 pm

Re: RFID reader question

Post by Franklin97355 »

Where is the "Seems to be.........." Print statement coming from? What are you expecting the output to be?

User avatar
FutureEngineer
 
Posts: 59
Joined: Sat Dec 26, 2015 5:11 pm

Re: RFID reader question

Post by FutureEngineer »

I need to display different messages for each card

User avatar
FutureEngineer
 
Posts: 59
Joined: Sat Dec 26, 2015 5:11 pm

Re: RFID reader question

Post by FutureEngineer »

Good morning,

Can you please check my code for any errors?
I used the code from readMifareClassic from the Adafruit-PN532 library.

Thanks in advacne for your support

User avatar
Franklin97355
 
Posts: 24414
Joined: Mon Apr 21, 2008 2:33 pm

Re: RFID reader question

Post by Franklin97355 »

What is the output when you run your code?

User avatar
FutureEngineer
 
Posts: 59
Joined: Sat Dec 26, 2015 5:11 pm

Re: RFID reader question

Post by FutureEngineer »

Good morning,

It's working now, I added an image.
I have one additional question, I need to connect parallel LCD with Arduino to display the name of the card owner.I want to ask which pins I can not use. I mean the pins used by the RFID reader that I can not use to connect the parallel LCD.

Thanks in advance
Attachments
RFID.png
RFID.png (198.48 KiB) Viewed 41 times

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

Return to “For Educators”