Elechouse PN532 NFC Module V3 for Arduino etc.



  • Hi all,

    I've ordered the same module and fighting with that for more that a week, but without any success. I've the version 3 of the NFC module and WDLduino UNO. I've switched the NFC module to use I2C (switch 1 on, switch 2 off). The problem is, that the sample code does not go through the initialization state, so the loop never starts. Also the initialization does not write that the board is not found, it only hangs. What is also interesting, that the power light on the NFC module is also off.
    I've 2 ARDUINOs (the same type) and also two NFC modules (ordered from different stores), but both have the same issue. Do you have any idea, what could be the problem or what else can I check?

    Some additional notes: I've turned on the debugging on the NFC library, so I know, that the code is hanging on PN532_I2C::wakeup, the _wire->endTransmission(); never comes back (PN532_I2C.cpp).

    1_1477689766616_IMG_5005.JPG
    0_1477689766615_freeze.png

    Any idea or help would be appreciated.


  • Community Helper

    Hi @Pingi , what you've got there so far all looks correct physically, but the fact that the power light isn't coming on is interesting - it definitely should when power is connected, regardless of what is running on the code side of things.
    You might need to double check all that, possibly use a multimeter to make sure that you're actually getting power at the reader unit.



  • Hey guys, need your help with similar problem as discussed earlier. My PN532 NFC module V3 won't work in I2C mode. I've switched the switch to correct possition, I've tried with both 3.3V and 5V. The module is powered (LED is on). When everything is connected, the COMM manager only says "Hello" and nothing else. If I disconnect one of the cables, it will say "Didn't find PN53x board". I have changed the initial "elif" statement, as written in the handbook, so it will work in I2C mode. However, I still can't get past the "Hello".
    Any suggestions?
    Many thanks ;)



  • I have the same issue. I am trying to conect a elechouse PN532 NFC module V3 to arduino nano and nothing. Same problem. Only says "hello".


  • Community Helper

    What code and libraries are you guys using to try to make it happen?



  • Hi @Lokki, thanks for you answer, I've tried a lot of different ways, how to power the NFC board, but the power led is still off. So, I've decided to open a complain at the store where I've bought the NFC shield, as in my opinion, the power led should at least work, otherwise the shield is non-functional.


  • 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?!