2

I've been struggling to get the PN532 module working over SPI with an Arduino Uno.
I have the wires connected as follows:

SCK   -> 13  
MISO  -> 12
MOSI  -> 11
SS    -> 10
VCC   -> 5V
GND   -> GND

And the board mode set for SPI as follows:
enter image description here

When I run the code below I get this output:

-------Peer to Peer HCE--------
write:  02
Time out when waiting for ACK
Didn't find PN53x board

Code:

#include <SPI.h>
#include <PN532_SPI.h>
#include "PN532.h"

PN532_SPI pn532spi(SPI, 10);
PN532 nfc(pn532spi);

void setup() {    
    Serial.begin(115200);
    Serial.println("-------Peer to Peer HCE--------");

    nfc.begin();

    uint32_t versiondata = nfc.getFirmwareVersion();
    if (! versiondata) {
      Serial.print("Didn't find PN53x board");
      while (1); // halt
    }

    // Got ok data, print it out!
    Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX); 
    Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC); 
    Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);

    // configure board to read RFID tags
    nfc.SAMConfig(); 
}

void loop()
{
    // Truncated
}

I've been trying to edit the source files and find the problem but I cannot seem to find whats causing it. Some help is much appreciated :)

  • According to dangerousthings.com/wp-content/uploads/PN532_Manual_V3-1.pdf you are doing everything correctly, Uno pins and supply voltage is okay.. Can you invert the two switch positions for interface selection for fun? Can you try their example code from the PDF? Can you try the I2C interface? – Maximilian Gerhardt Mar 11 '18 at 14:02
  • @MaximilianGerhardt I cannot use anything else than SPI, because I probably broke the SDA and SCL soldering points when trying to resolder them... (Perhaps this explains the weird behavior and is the chip dead, but I am refusing to believe that for now). Concerning the code, this is the exact code from their GitHub. – Floris Mar 11 '18 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.