4 PN532 SPI Arduino Nano

Hello,

I'm trying to use 4 PN532 in SPI.
When there is only one reader it read all the times, but when the 4 are active only 1 of them can read.
Here's my code, I tried forcing SS pin LOW and HIGH but none of the readers can read after that.
Do you have any idea of what causing this ?

#include <SPI.h>
#include <Adafruit_PN532.h>

#define SCK 13
#define MOSI 11
#define MISO 12

/*pins de selection d'esclave*/
#define SS_1_PIN 5
#define SS_2_PIN 4
#define SS_3_PIN 9
#define SS_4_PIN 8

/*tableau des pins de selection d'esclave*/
byte ssPins[] = { SS_1_PIN, SS_2_PIN, SS_3_PIN, SS_4_PIN };

/*nombre de lecteur RFID*/
#define NB_OF_READERS 4

Adafruit_PN532 nfc1(SCK, MISO, MOSI, SS_1_PIN);
Adafruit_PN532 nfc2(SCK, MISO, MOSI, SS_2_PIN);
Adafruit_PN532 nfc3(SCK, MISO, MOSI, SS_3_PIN);
Adafruit_PN532 nfc4(SCK, MISO, MOSI, SS_4_PIN);

Adafruit_PN532 nfcs[] = { nfc1, nfc2, nfc3, nfc4 };

void setup(void) {
  Serial.begin(115200);
  Serial.println("Hello!");

  //bloquer toute communication des lecteurs RFID
  for (byte ssPin = 0; ssPin < NB_OF_READERS; ssPin++) {
    pinMode(ssPins[ssPin], OUTPUT);
    digitalWrite(ssPins[ssPin], HIGH);
  }

  for (byte reader = 0; reader < NB_OF_READERS; reader++) {
    digitalWrite(ssPins[reader], LOW);

    nfcs[reader].begin();

    uint32_t versiondata = nfcs[reader].getFirmwareVersion();
    if (!versiondata) {
      Serial.print("Didn't find PN53x board");
      while (1)
        ;
    }
    Serial.print("Found chip PN5");
    Serial.println((versiondata >> 24) & 0xFF, HEX);
    nfcs[reader].SAMConfig();

    digitalWrite(ssPins[reader], HIGH);
  }

  Serial.println("Waiting for an ISO14443A Card ...");
}

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)

void loop(void) {

  for (int i = 0; i < NB_OF_READERS; i++) {

    success = nfcs[i].readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength, 100);
    
    Serial.print(i);
    Serial.print(" : ");
    if (success) {

      for (int l = 0; l < uidLength; l++) {
        Serial.print(uid[l] < 0x10 ? "0" : "");
        Serial.print(uid[l], HEX);
      }
      Serial.println("");
    } else {
      Serial.println("Impossible");
    }
    Serial.println("");
    delay(10);
  }
}

Please post schematics.


Here it is.

Sorry, pictures are not very informative.
Can you please draw a schematic and post an image of it?
Please include power supplies, component names and pin labels.
Where are you getting the 3V3 power supply from?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

Hope this is better :slight_smile:

The 3V3 is provided by the Arduino

The main power is via USB and from 5V 2.4A wall adapter via 5V Arduino pin.

Have you checked the spec on the Nano's 3V3 output.
Have you checked the RFID current consumption, especially during a sensing cycle?

This might help, look at the transmission current.

Can you please post a link to where you purchased the RFID and a data/spec sheet?

Tom.... :smiley: :+1: :coffee: :australia:

Arduino Nano provide max 800mA 3V3, the PN532 draw 60mA typ. and 150mA max.
Don't think that it draw 150mA in my application.
Only one reader is active at the time (or am I wrong) ?
When I test only one PN532, the others are connected and draw power.
I bought them on amazon :

It draws that current when it transmits to the tag to wake the tag up.

Where did you get 800mA at 3V3, here it says 5V 800ma, 3V3 is 100mA MAX.

Tom... :smiley: :+1: :coffee: :australia:
PS. G'dnight, I'm off to bed.. :sleeping: :sleeping: :sleeping: :sleeping:

Oh damn I misread...
So there is no way the arduino can supply enough current for all 4 readers, even one.
Maybe if I power up only one at the time it may be ok.

Have a good night :slight_smile:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.