Elechouse PN532 NFC Module V3 for Arduino etc.


  • Community Helper

    So, I got one of these on ebay and after a false start concerning poor library installation it is up and running and making good reads and/or writes.
    This unit supports 5 volt I2C or 3.3 volt SPI as well as a HSU option that I haven't tried, I've been using it in I2C mode and have successfully tried it with Arduino Duemilanove, Uno, Mega2560 and Microduino.
    It will read ring inlays within 15mm on the top side or about half that from the rear.
    The board is 42.7mm x 40.4mm, impressively small and I've seen them on ebay very cheap.


  • NFC Ring Team

    Yea they work great. I'm a huge fan of these modules with the ring. +1 for bringing it up.. I'd love it if we could purchase a load as a collective and bring the price down..


  • Community Helper

    Yeah definitely. If that were to happen I'd love to be on board. I'm going to be using quite a few of these in the future I suspect.



  • Got my elechouse today. Different distributor I believe. Doesn't seem to be working with any ntag. It came with a different lib than yours, so I will try out different libs later. Works fine with the tags that came with it.

    /e got my module working with ntag using the lib from yours. Unfortunately my ring is not reading at all, looks like its finally time to give up and send in for a replacement :(





  • Hi,

    I'm very new to this module and Arduino but I'm currently studying it and try to write something to the EEPROM. Anyone can share some of your code on how to write and read to tags by this module?

    Thanks.



  • I tried the Elechouse Module v3 with the libraries that are provide by Elechouse on an Arduino Uno.
    Hardware serial works, but I can't make it work with I2C. The module simply isn't recognized. I'd like to keep the serial port free for other purposes.
    Firmware shows version 1.4.

    Are there newer libraries?
    Any help to get this working with I2C would be appreciated.



  • @OniMoxy Try to connect the VCC to the 3.3V.
    It fixed the problem for me.


  • Community Helper

    Did you change the switches? the board has a different default mode


  • Community Helper

    @Lafunamor's suggestion first, make sure it's reading in the right mode and your sketch is setting up for that mode correctly. Then mess with the input voltage if you need to as per @Nairod785's suggestion.



  • I have set the switches for I2C mode.
    Connecting to 3.3V instead of 5V didn't help.

    Funny thing is if I disconnect VCC shortly while the Arduino sketch is running setup() then it works!
    It skips getting the firmware version, goes into loop() mode and waits for a card.
    I place a card and it detects it!

    I think there is something wrong with the PN532_I2C library.

    I also found that it does work with the nfc library (nfc.cpp + nfc.h) that Elechouse provides.
    So I am going to use that one instead.



  • I'm using it with arduino uno...its showing "board pn53x not found"...what can i do?


  • Community Helper

    Make sure your PN532 board is connected to the arduino correctly, and its power light is on.
    What method are you using for the connection?



  • yeah..the power light is on...i connected vcc --> 5v ; gnd --> gnd ; sda --> A4 ; scl --> A5


  • Community Helper

    That does seem like it should be right, sometimes if sda and scl are swapped you'll get nothing.
    Is your sketch set up for using IIC correctly?



  • @Lokki Yeah..i'm using the example of the library provided by elechouse



  • Still can u send me any of your code..!?


  • Community Helper

    Search the forums, I've left bits and pieces of horrendous code around here before.
    It would actually be better if you show us your code. From a troubleshooting point of view, like.



  • #if 0
    #include <SPI.h>
    #include <PN532_SPI.h>
    #include <PN532.h>
    #include <NfcAdapter.h>
    
    PN532_SPI pn532spi(SPI, 10);
    NfcAdapter nfc = NfcAdapter(pn532spi);
    #else
    
    #include <Wire.h>
    #include <PN532_I2C.h>
    #include <PN532.h>
    #include <NfcAdapter.h>
    
    PN532_I2C pn532_i2c(Wire);
    NfcAdapter nfc = NfcAdapter(pn532_i2c);
    #endif
    
    void setup(void) {
        Serial.begin(9600);
        Serial.println("NDEF Reader");
        nfc.begin();
    }
    
    void loop(void) {
        Serial.println("\nScan a NFC tag\n");
        if (nfc.tagPresent())
        {
            NfcTag tag = nfc.read();
            tag.print();
        }
        delay(5000);
    }
    

  • Community Helper

    Okay, for comparison I'm going to copypasta my crappy car starter sketch:

    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.begin(115200);
      Serial.println("Hello! I'm a Car!");
    
      nfc.begin();
    
      uint32_t versiondata = nfc.getFirmwareVersion();
      if (! versiondata) {
        Serial.print(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.
      nfc.setPassiveActivationRetries(0xFF);
      
      // configure board to read NFC tags
      nfc.SAMConfig();
        
      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("..");
          Serial.print(uid[i], HEX);
          ringUid += String(uid[i], HEX);
    
        }
        Serial.println(ringUid + "\n");
        if (ringUid == "xxxxxxxxxxxxxx" || ringUid == "xxxxxxxxxxxxxx" || ringUid == "xxxxxxxxxxxxxx" || ringUid == "xxxxxxxxxxxxxx"){
          Serial.println("Key accepted!");
      }
        
        
        if ((ringUid == "xxxxxxxxxxxxxx" || 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 == "xxxxxxxxxxxxxx" || 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 == "xxxxxxxxxxxxxx" || 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
        delay(3000);
        carRunState = 0;
        digitalWrite(indicatorPin1, LOW); //LED1 off
      }
      }
    }
    

Log in to reply
 

Looks like your connection to NFC Ring Forum was lost, please wait while we try to reconnect.