Elechouse PN532 NFC Module V3 for Arduino etc.

  • NFC Ring Team

    Great job @Lokki !! :)

  • One more thing...the module is not reading my nfc tags having Topaz 512 chip...can u please tell me the module is compatible with which nfc tags other than mifare?

  • Community Helper

    No worries at all, dude. I like it best when things work!
    TBH I've only really used my gear with mifare classics and NTAG based tags/fobs/rings/etc. (I've never used a Topaz in any form.)

    From the manual it says this:

    RFID reader/writer mode support
     Mifare 1k, 4k, Ultralight, and DesFire cards
     ISO/IEC 14443-4 cards such as CD97BX, CD light, DesFire, P5CN072 (SMX)
     Innovision Jewel cards such as IRT5001 card
     FeliCa cards such as RCS_860 and RCS_854

    I have found though that your mileage may vary as to where and how well you read some things. You might need to play around with it a bit to get best results.

  • When I try to write on the mifare classic......the serial monitor shows....block authentication failed for 4..what to do?


    #include <Wire.h>
    #include <PN532_I2C.h>
    #include <PN532.h>   // The following files are included in the libraries Installed
    #include <NfcAdapter.h>
    PN532_I2C pn532_i2c(Wire);
    NfcAdapter nfc = NfcAdapter(pn532_i2c);  // Indicates the Shield you are using
    void setup() {
        Serial.println("NFC Tag Writer"); // Serial Monitor Message
    void loop() {
        Serial.println("\nPlace an NFC Tag that you want to Record these Messages on!"); // Command for the Serial Monitor
        if (nfc.tagPresent()) {
            NdefMessage message = NdefMessage();
            message.addTextRecord("Abc"); // Text Message you want to Record
                    boolean success = nfc.write(message);
            if (success) {
                Serial.println("Good Job, now read it with your phone!"); // if it works you will see this message 
            } else {
                Serial.println("Write failed"); // If the the rewrite failed you will see this message
    Yes you can wrap the code with 3 backticks.

  • It says "the tag is not NDEF Formatted"....so should it be NDEF formatted to use it with the module?

  • Community Helper

    Ah, you may have to look into that - have a read up on the mifare classic data sheet.

  • hey lokki
    long time no see

    I'm finally got some more free time so I'm back to working out what the hell I'm doing :P

    coud I ask with your mr crappy car code...if I'm getting a uid value as follows

    where does that information need to be put for the code to accept it as one of the valid keys?

  • Community Helper

    Howdy again, @MarkGabb
    It should look something like this:

    int triggerPin1 = 2;
    int triggerPin2 = 3;
    int triggerPin3 = 4;
    int indicatorPin1 = 5;
    int indicatorPin2 = 6;
    int indicatorPin3 = 7;
    int indicatorPin4 = 8;
    int handbrakePin1 = 9;
    int carRunState = 0;
    int handbrakeState = 0;
      #include <Wire.h>
      #include <PN532_I2C.h>
      #include <PN532.h>
      PN532_I2C pn532i2c(Wire);
      PN532 nfc(pn532i2c);
    void setup(void) {
      pinMode(triggerPin1, OUTPUT);
      pinMode(triggerPin2, OUTPUT);
      pinMode(triggerPin3, OUTPUT);
      pinMode(indicatorPin1, OUTPUT);
      pinMode(indicatorPin2, OUTPUT);
      pinMode(indicatorPin3, OUTPUT);
      pinMode(indicatorPin4, OUTPUT);
      pinMode(handbrakePin1, INPUT);
      Serial.println("Hello! I'm a Car!");
      uint32_t versiondata = nfc.getFirmwareVersion();
      if (! versiondata) {
        Serial.print("PN53x key scanner board not online");
        while (1); // halt
      // Got ok data, report state
      Serial.print("Reader Online, ");
      // Set the max number of retry attempts to read from a card
      // This prevents us from waiting forever for a card, which is
      // the default behaviour of the PN532.
      // configure board to read NFC tags
      Serial.println("Waiting for a valid key");
    void loop(void) {
      String ringUid;
      boolean 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)
      // Wait for an ISO14443A type cards (NFC Ring, Mifare, etc.).  When one is found
      // 'uid' will be populated with the UID, and uidLength will indicate
      // if the uid is 4 bytes (Mifare Classic) or 7 bytes (NFC Ring or Mifare Ultralight)
      success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength);
      if (success) {
        // Display some basic information about the card
    //    Serial.print("  UID Length: "); Serial.print(uidLength, DEC); Serial.println(" bytes");
        Serial.print("  UID Value: ");
        for (uint8_t i = 0; i < uidLength; i++)
          Serial.print(uid[i], HEX);
          ringUid += String(uid[i], HEX);
        Serial.println(ringUid + "\n");
        if (ringUid == "42cbfd26f3f81" || ringUid == "xxxxxxxxxxxxxx" || ringUid == "xxxxxxxxxxxxxx" || ringUid == "xxxxxxxxxxxxxx"){
          Serial.println("Key accepted!");
        if ((ringUid == "42cbfd26f3f81" || ringUid == "xxxxxxxxxxxxxx" || ringUid == "xxxxxxxxxxxxxx" || ringUid == "xxxxxxxxxxxxxx") && (carRunState == 0)){
          Serial.println("PERMISSION GRANTED, SYSTEMS ON");
          digitalWrite(triggerPin3, HIGH);   // sets latching relay trigger on for ignition mode in car to allow start
          digitalWrite(indicatorPin2, HIGH); //show state, second LED
          delay(200);                  // waits briefly
          digitalWrite(triggerPin3, LOW);    // removes latching relay trigger
          carRunState = carRunState++;
        else if ((ringUid == "42cbfd26f3f81" || ringUid == "xxxxxxxxxxxxxx" || ringUid == "xxxxxxxxxxxxxx" || ringUid == "xxxxxxxxxxxxxx") && (carRunState == 1)){
          handbrakeState = digitalRead(handbrakePin1); //check if handbrake is on or off
          if (handbrakeState = 0){//if handbrake is on then safe to crank car, if not then skip this mode entirely
            Serial.println("ENGINE CRANKING");
            digitalWrite(triggerPin1, HIGH);   // triggers output for engine starting
            digitalWrite(indicatorPin3, HIGH); //show state, third LED
            delay(2000);                  // waits for a second
            digitalWrite(triggerPin1, LOW);    // removes triggered output 
            Serial.println("ENGINE CRANKING COMPLETE");
          carRunState = carRunState++;     
        else if ((ringUid == "42cbfd26f3f81" || ringUid == "xxxxxxxxxxxxxx" || ringUid == "xxxxxxxxxxxxxx" || ringUid == "xxxxxxxxxxxxxx") && (carRunState > 1)){
          Serial.println("SYSTEM OFF, SLEEP TIME");
          digitalWrite(triggerPin2, HIGH);   // Trigger latching relay to reset for vehicle OFF
          digitalWrite(indicatorPin1, HIGH); //show state, LED1 on
          digitalWrite(indicatorPin2, LOW); //LED2 off
          digitalWrite(indicatorPin3, LOW); //LED3 off
          delay(200);                  // waits briefly      
        digitalWrite(triggerPin2, LOW);    // Removes latching relay reset trigger
        carRunState = 0;
        digitalWrite(indicatorPin1, LOW); //LED1 off

    If you're not using one of the ringUid bits then just delete it, the sketch can work with only one ring set up or it can work with 12. I had it set up with two rings, front and back, so that myself and the girlfriend could start the car and didn't have to worry about which way the ring was facing.

  • Hmmm this script seems very different to the one I've got loaded.....made some improvments??

  • Ok so ill upload tonight, ive forgotten physical pin mapping
    Arduino nano

    I know my reader is in a4 and a5 and is correct because the reader is showing in the terminal

  • Community Helper

    yeah, I think the one you grabbed a while back would have been seperate cards for on/ignition/off. It was a while back.
    Just set the pins however you want them, it's pretty arbitrary. I think from memory the handbrakepin1 basically does nothing, you could chop that out.

  • Sorry question wasn't terribly clear... I forget how to actually assign pins. so if I wanted trigger pin1 to be b5 do I just change the 2 to b5?

  • Lol strait back and full of questions

    So I've loaded the code and input my keys.... however I don't get any further messages from the board about state it just reads the uid back to be over and over... shouldnt get a message about state from the board?

  • Community Helper

    Yeah it should be returning a state like "key accepted" or whatever I've got written in there. Read the uid in however many tags/rings you've got and enter them in, re-load the sketch and see what happens - I may have pasted the uid in wrong.

  • Yeah I reloaded it and loaded in both rings it was reading, as well as the one I sent you...wjich I got the uid from the terminal windownnnwhich means I must be getting the right id

    but no go

  • Hello! I'm a Car!
    Reader Online, Waiting for a valid key
      UID Value: ..4..B..4C..22..99..3C..814b4c22993c81
      UID Value: ..4..B..4C..22..99..3C..814b4c22993c81
      UID Value: ..4..32..32..22..99..3C..814323222993c81
      UID Value: ..4..32..32..22..99..3C..814323222993c81

     Serial.println(ringUid + "\n");
     if (ringUid == "42cbfd26f3f81" || ringUid == "814b4c22993c81" || ringUid == "814323222993c81" || ringUid == "xxxxxxxxxxxxxx") {
        Serial.println("Key accepted!");

  • ok poured over this again last night...im positive im missing something, but really no idea what it is...
    anyone with some programing experience got any tips on why this wouldnt be working?

  • Community Helper

    @MarkGabb said in Elechouse PN532 NFC Module V3 for Arduino etc.:

    Hello! I'm a Car!
    Reader Online, Waiting for a valid key
      UID Value: ..4..B..4C..22..99..3C..814b4c22993c81
      UID Value: ..4..B..4C..22..99..3C..814b4c22993c81
      UID Value: ..4..32..32..22..99..3C..814323222993c81
      UID Value: ..4..32..32..22..99..3C..814323222993c81

     Serial.println(ringUid + "\n");
     if (ringUid == "42cbfd26f3f81" || ringUid == "814b4c22993c81" || ringUid == "814323222993c81" || ringUid == "xxxxxxxxxxxxxx") {
        Serial.println("Key accepted!");

    heh. I can see one thing wrong at least. 4b4c22993c81 not 814b4c22993c81 and 4323222993c81 not 814323222993c81

  • Community Helper

    If that doesn't work I'd recommend installing nxp taginfo on an android device, read your ring and take the UID from the "tech" tab. There are zeros that may be necessary. eg. 04 0B 4C 22 99 3C 81
    Don't forget to kill the process before locking your device if you're using the nfc ring unlock app.

  • @Lokki spot on. i read the tag reading the wrong way around
    im guessing it wont pass to next section until i have the circuits completed...
    i remove the part when it checks for handbrakes and have just set it to 0 permanantly

    it wont say engine cranking, but im pretty sure that because nothing other than nfc reader is connected to it

    do you know anyone who has done an eagle for this??
    i think this is worthy of sending the board out for proper creation