title: NFC - Help to exchange data between RC522 & Android HCE
body: <p>I will explain my project :</p>
  
  <p>I have my RC522 and a door connected on my Arduino UNO.</p>
  
  <p>I can currently open the door with a MIFARE classic.</p>
  
  <p>But now I want to open it with my Android smartphone, this is why I develop a HCE applet to accept the good APDU with the selected AID, then my phone will transfer the data in order to open the door.</p>
  
  <p>But the problem is : </p>
  
  <p>I don't know how to send an APDU command with my Arduino using the RC522.</p>
  
  <p>Currently, for my MIFARE Cards, I use the <a href="https://github.com/miguelbalboa/rfid" rel="nofollow">https://github.com/miguelbalboa/rfid</a> library.</p>
  
  <p>My test code :</p>
  
  <pre><code>byte selectApdu[] = { 
    0x00, /* CLA */
    0xA4, /* INS */
    0x04, /* P1  */
    0x00, /* P2  */
    0x05, /* Length of AID  */
    0xF2, 0x22, 0x22, 0x22, 0x22,
  };
  byte * backData = (byte *)malloc(16*sizeof(byte));
  byte * dataLen = (byte *)16;
  
  status = mfrc522.PCD_TransceiveData(selectApdu,10,backData,dataLen,NULL,0,false);
  if ( status != MFRC522::STATUS_OK) {
      Serial.print(F("PCD_TransceiveData() failed: "));
      Serial.println(mfrc522.GetStatusCodeName(status));
      return;
  }
  else
  {
    Serial.println(F("PICC_TransceiveData() success "));
  }
  </code></pre>
  
  <p>Neverless, it doesn't work ( "Timeout in communication"), and I slowly need to think that the RC522 is not compatible...</p>