Connecting multiple I2C NFC antenna using 2 mux

Hello,

Hope you will be able to assist me with an issue I have.

First, my intention is to connect about 9 NFC antennas (I2C) using 2 multiplexers.
Using 2 analog multiplexers (1 to 16) with external power, what I’m actually trying to do is to mimic I2C communication to Arduino using the 2 outputs from each multiplexer.
Each antenna connected to the multiplexers in this way:
all SCL’s connected to mux1
all SDL’s connected to mux2
by changing the select lines I’m choosing a specific channel in both muxs, using pins A4,A5 to communicate with the specific antenna from the specific channel (I2C).

Using the code below, it seems that in some cases I’m getting response from each one of the antennas through the multiplexers, and in some other cases it seems that it get stuck or having a huge response time.

Will be happy to understand if my design is legit for my purpose, and if I’m using the code properly.

#include <PN532_I2C.h>
#include <PN532.h>
#include <NfcAdapter.h>

PN532_I2C pn532_i2c(Wire);
PN532 nfc(pn532_i2c);

int pin_Out_S0 = 3;
int pin_Out_S1 = 5;
int pin_Out_S2 = 6;
int pin_Out_S3 = 9;
int antenaNum = 8;

void setup(void)
{
  Serial.begin(115200);
  pinMode(pin_Out_S0, OUTPUT);
  pinMode(pin_Out_S1, OUTPUT);
  pinMode(pin_Out_S2, OUTPUT);
  pinMode(pin_Out_S3, OUTPUT);
  uint32_t versiondata;
  for (int i = 0; i < antenaNum; i++) {
    Serial.print("setup start of antena ");
    Serial.println(i);
    switchMux(i);
    delay(2500);
    nfc.begin();

    versiondata = nfc.getFirmwareVersion();
    if (! versiondata)
    {
      Serial.println("Didn't find PN53x board");
    }
    else
    {
      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.setPassiveActivationRetries(0x12);
      nfc.SAMConfig();
      delay(100);
    }
    Serial.println("---------------------------------------------");
  }
}
void loop() {
  Serial.println("Loop");
  boolean success;
  uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
  uint8_t uidLength;
  for (int i = 0 ; i < antenaNum; i++) {
    switchMux(i);
    success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength);
    if (success) {
      Serial.print("---------Scan a NFC tag #");
      Serial.print(i);
      Serial.println(" -------");
      Serial.println("Found a card!");
      Serial.print("UID Length: "); Serial.print(uidLength, DEC); Serial.println(" bytes");
      Serial.print("UID Value: ");
      for (uint8_t c = 0; c < uidLength; c++)
      {
        Serial.print(" 0x"); Serial.print(uid[c], HEX);
      }
      Serial.println("");
      delay(300);
    }
  }
}

New to me, so I had to Google for some research on NFC antennas and their use. Where do you generate the 13 Mhz signal and where do you receive it?

Paul

Hello Paul, thanks for your response :slight_smile:

Not sure exactly what you mean by generating 13 Mhz signal.
I'm using these NFC antenna - XADOW - NFC using I2C protocol for communication.
The NFC antenna is not really the issue - the issue is how to communicate with 9 (and more) components that using I2C via mux.

I read in one of the forums that all SCL should be connected together, didn't test it yet.

Thanks
Oren

Oren,

I think that you have confused Paul_KD7HB by calling the item that you are using an antenna, when it is in fact :

a highly integrated transceiver module PN532 which handles contactless communication at 13.56MHz.

The 13MHz signal is generated by the module itself.

JohnLincoln:
Oren,

I think that you have confused Paul_KD7HB by calling the item that you are using an antenna, when it is in fact :

The 13MHz signal is generated by the module itself.

Thank you! My mind reader is not functioning this morning.

Paul

Your first problem: you block Serial for a too long time!

You should exit loop() after at most handling one ID, so that the Serial output really can be sent. For better timing see BlinkWithoutDelay and state machines.