PN532 NFC/RFID reading multiple tags

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
andystr
 
Posts: 2
Joined: Sat Feb 21, 2015 7:52 am

Re: PN532 NFC/RFID reading multiple tags

Post by andystr »

Hey to everyone,
i was trying to reproduce what "uniapa" said about deselecting each tag after reading. It was not working out for me. I was using the iso14443a_uid example from the arduino library. I get exactly the same behavior as if i did not add the code that "uniapa" mentioned. How exactly where you calling the readPassiveTargetID function in your arduino sketch? Any other modifications.

I want to read exactly 2 cards stacked above each other.

thank you in advance

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: PN532 NFC/RFID reading multiple tags

Post by adafruit_support_mike »

It's possible, but our library doesn't support multiple cards.

User avatar
andystr
 
Posts: 2
Joined: Sat Feb 21, 2015 7:52 am

Re: PN532 NFC/RFID reading multiple tags

Post by andystr »

Thank you for your answer.
Your library actually does support two cards with minor modification. All i had to do was change the readPassiveTargetID function. Basically you only need to change this portion of the code:

Code: Select all

boolean Adafruit_PN532::readPassiveTargetID(uint8_t cardbaudrate, uint8_t * uid1, uint8_t * uid2, uint8_t * uidLength) {
  pn532_packetbuffer[0] = PN532_COMMAND_INLISTPASSIVETARGET;
  pn532_packetbuffer[1] = 2;  // max 2 cards at once 
  pn532_packetbuffer[2] = cardbaudrate;
  
  if (! sendCommandCheckAck(pn532_packetbuffer, 3))
    return 0x0;  // no cards read
  
  // read data packet
  readspidata(pn532_packetbuffer, 31);
  // check some basic stuff

  /* ISO14443A card response should be in the following format:
  
    byte            Description
    -------------   ------------------------------------------
    b0..6           Frame header and preamble
    b7              Tags Found 
    b8              Tag Number (only one used in this example)
    b9..10          SENS_RES
    b11             SEL_RES
    b12             NFCID Length
    b13..b19  		NFCID
    -------------   ------------------------------------------
    for 2 mifare ultralight tags:
    -------------   ------------------------------------------
    b20      	    Tag Number
    b21..22         SENS_RES
    b23             SEL_RES
    b24             NFCID Length
    b25..b31  		NFCID                                 */
  
I adjusted the maximum amount of cards to two and increased the packetbuffer to 31 to store all values of two tags.
This works as expected, but the reading process gets to slow for me, it takes drastically longer than reading with the maximum amount of cards set to 1.

Thats why i wanted to know if the method that "uniapa" described actually worked, because i wasnt able to reproduce what he said.

The way he explained he deactivates each tag in the field by using the INDESELECT command at the end of readPassiveTargetID. But the way i understand this is, the tags get activated again in the next loop when the reader is searching for them. So i dont see how this should work.

Any hints anybody?

Best regards
Andy

User avatar
lukejones27
 
Posts: 5
Joined: Mon Mar 11, 2019 1:57 pm

Re: PN532 NFC/RFID reading multiple tags

Post by lukejones27 »

I recently started a project which I aim to read multiple tags and come across this forum thread. Has there been any head way made with being able to read multiple tags? I was looking at having multiple tags on the shield and reading each one then ignoring that tag an reading another then ignoring that tag and the previous etc.

Any help or information on this would be appreicated!

Thanks

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

Return to “Arduino Shields from Adafruit”