Elechouse PN532 NFC Module V3 for Arduino etc.


  • Community Helper

    @Pingi No worries. With mine, the power led is on when power is applied, no matter whether data is hooked up or not.



  • @Lokki Hey, thanks for getting back to me. I'm using the recomended library by Elechouse (on github under elechouse/PN532) together with included NDEF library. I also tried Don's NDEF library, but I think they're the same.


  • Community Helper

    @zafod no worries. Just make sure that you've extracted the libraries correctly (it was a couple of windows installs ago for me now, but there was difficulty in placing/extracting directories with one of the library sets).
    Then maybe try it with my dodgy bit of code, just to see what happens - that will still let you view output from the reader the same way.



  • I could make it work.(sorry from my english..I am an uruguayan native :) )
    I took my libraries from this tutorial:
    http://www.instructables.com/id/NFC-Ring-Lock-Box/
    Also , this are some steps that i did:

    • I asigned read/write permissions to arduino libraries folder.
    • Just put on libraries the same from tutorial
    • I changed the conexion pin to 3.3V , not 5V from arduino to nfc reader.
    • Before upload the code, y pressed arduino nano reset button some seconds!, after that y upload the code.
    • I modified the code removing that was not required.
      Its seems that the lines thats gets the firmware doesn´t work.

    This is the code( i don´t wnow hoy to formatead it)

    #include <Wire.h>
    #include <PN532_I2C.h>
    #include <PN532.h>
    
    PN532_I2C pn532i2c(Wire);
    PN532 nfc(pn532i2c);
    
    void setup() {
      Serial.begin(115200);
      Serial.println("Hello!");
      nfc.begin();
      nfc.SAMConfig(); // configure board to read RFID tags
      Serial.println("Waiting for an ISO14443A card");
    }
    
    void loop() {
      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
      
      success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength);
    
      if (success) {
        Serial.println("Found a 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(" 0x");
          Serial.print(uid[i], HEX);
          ringUid += String(uid[i], HEX);
        }
    
        Serial.println("");
        // Wait 1 second before continuing
        delay(1000);
      }
    }
    

    (edit) indent express train ran by @andreas


  • Community Helper

    @Javier, glad you're back.
    I've fixed the code insertion, if you "edit" your post you'll see what I've done with the three backticks at the start and end of the code there.

    Have you got the libraries installed on your computer properly? These are the ones I use, they're for the module.

    https://github.com/elechouse/PN532

    Make sure that you follow these instructions, they're on the front page of the github:

    Getting Started

    Download zip file and extract the three folders(PN532, PN532_SPI, PN532_HSU and PN532_I2C) into libraries of Arduino.
    Downlaod Don's NDEF library and extract it into libraries of Arduino's into a new folder called "NDEF" (Note if you leave this folder as NDEF-Master Arduino will not be able to use it as a library)
    Follow the examples of the PN532 library



  • I already tried with that libraries without success. My only interest was to make it work with I2C mode so, the tutorial fits perfect for me. I also read on internet that all libraries where not necesaries, just only 2 on my case.

    From internet I found people that make it work doing some of one of the step that i did.
    Example: reset the button, removing firmware lines of code, changing voltage source from 5v to 3.3V.

    Perhaps, libraries where not my problem, I not isolated the real problem.
    Perhaps the problem is the combination of chinese arduino nano V3.0 with elechouse nfc reader V2.0.
    It's cost me a lot of investigation to make it work with that combination.

    My next step is comunicate nfc readings with my raspberry trought arduino. :D


  • Community Helper

    @Javier ah, ok.
    It seems like you're not getting anything back at all from the PN532 module to indicate that communication with the arduino has started, so there's definitely an issue there of some sort. Whether it's programming, the wiring or the clone arduino is tricky to say (especially over the internet without seeing things in front of me).



  • Hi @Lokki ,
    My complaint regarding the NFC shield was accepted by the seller, so I ordered a new board. With this new board I got a step further, the power led is now working, but the card detection still now, the code does not goes through the initialization phase (nfc.begin()), it just holds on that line and never returns. Do you have any idea what could be the problem? I'm absolutely disappointed, as this is the third NFC shield and I'm still at the same stage ...
    I'm using I2C communication, the switches were setup based on that (channel 1 on, channel 2 off), see picture below.
    0_1480274803938_nfc.JPG

    Any idea would be really appreciated!


  • Community Helper

    @Pingi that's definitely better than the last one!

    Just to step back from everything and clear things a little, if you guys need to troubleshoot I'd recommend going via the elechouse manual from ~page 5. Once you've verified that it is hooked up correctly and is functioning with the example code then you have a known point to work forward from.

    http://www.elechouse.com/elechouse/images/product/PN532_module_V3/PN532_ Manual_V3.pdf



  • @Lokki thanks for your suggestion, but that manual I have earlier than my first NFC shield. What I've understood from that manual I've used while wiring. The sample codes are also from there...
    I've checked the document 10 times also the wiring, tried to re-install the libraries, but the result is the same. That's why I've uploaded the photo, maybe you or somebody else has better eyes or more experience, what to check or where to look around...


  • Community Helper

    @Pingi are you still using 19200 as the serial speed? If so, could you try some other settings there, up to 115200?



  • hello
    I'm having the same problem: arduino one brake on the line nfc.begin();
    I'm new in arduino and nfc, but I've downloaded pn532 libraries, set pin 1-0 on the board, all the 4 wires are ok (vcc, gnd, sda, scl); the serial speed is set to 115200
    in this code:

      #include <Wire.h>
      #include <PN532_I2C.h>
      #include <PN532.h>
      #include <NfcAdapter.h>
      PN532_I2C pn532i2c(Wire);
      PN532 nfc(pn532i2c);
      
    void setup(void) {
      Serial.begin(115200);
      Serial.println("Hello!");
      nfc.begin();
      Serial.println("second Hello!");
    

    the serial write just the first Hello!
    I can't find a solution... Help me!!

    ok
    now it works!
    in SPI mode (jumper 0 - 1) and SCK MISO MOSI SS VCC GND

    thank you all
    Massimo



  • I, too, stops on the line nfc.begin(); if disconnect board or select another pin - Didn't find PN53x board. Connect to I2C. SPI don`t work too.

    hardware\arduino\avr\libraries\Wire\utility\twi.c

    uint8_t **twi_writeTo**(uint8_t address, uint8_t* data, uint8_t length, uint8_t wait, uint8_t sendStop)
    {
     . . . . . . . . . . . . . . . . . . . 
      // wait for write operation to complete
      while(wait && (TWI_MTX == twi_state)){
        continue; //**stops here**
      }
      
      if (twi_error == 0xFF)
        return 0;	// success
      else if (twi_error == TW_MT_SLA_NACK)
        return 2;	// error: address send, nack received
      else if (twi_error == TW_MT_DATA_NACK)
        return 3;	// error: data send, nack received
      else
        return 4;	// other twi error
    }
    


  • @Lokki , thanks for the hint. I've tried the whole range from 9600 up to 250000, but the result is the same.

    @Sergey , I think, that we both have the same issue, I've also checked the twi.c and my intention was that my code stopped on the same line. What the hell? Has anybody better understanding of the I2C protocol? Maybe the NFC shield is absolutely not responding to I2C protocol? But, I've 3 NFC shields of the same type but ordered from 3 different shops. The result is the same.... It's very hard to imagine, that all 3 shields are wrong, so the question is, what are we doing wrong?!



  • @Pingi Hi. I think you should write about this problem on stackoverflow. Maybe Michael Roland spots your question and helps you, he is quite good in NFC things! Dont forget to come back with the solution to this forum ;)!



  • Try the same that I did! Read my previous reply. I made it work.



  • @Javier, thanks for the hint. I did not understood all you tries, but I've verified the followings already:

    • resetting arduino
    • changing voltage source from 5v to 3.3V

    What I do not understand is:

    • removing firmware lines of code


  • Has anyone worked with this module on raspberry pi?!
    I just tried i2c connection, the raspberry pi is able to detect the device, but still I don't know which library will work. Please can someone help?!



  • Hey guys, found this Thread via google. I have exactly the same issue with a Arduino Nano and ElecHouse V3 Board. I have 3 boards ordered over an Aliexpress dealer.

    • wired via i2c
    • 3,3V used
    • switch set to 1/0 for i2c
    • downloaded the libraries from elechouse github
    • power LED on board is on
    • used demo code from elechouse (and the pieces posted above)
    • removed all unneeded code related to SPI and Serial
    • also tried with 2 additional 10k pullup resistors on I2C

    -> same problem on all 3 V3 Boards - the code hangs on "nfc.begin". I have added a 2nd serial print "Hello" after "nfc.begin". This Hello isn't printed, only the first one. So it definatly hangs on this point.

    If I disconnect GND from board on the "Hello" point I get this output (Debug is enabled on PN532_debug.h):

    Hello!
    write: 02
    wait for ack at : 9101
    Time out when waiting for ACK
    Didn't find PN53x board



  • Tried an other Arduino Nano - it works. So maybe the I2C Pins or smthg else was bricked on the Nano.