Elechouse PN532 NFC Module V3 for Arduino etc.
-
I'm using it with arduino uno...its showing "board pn53x not found"...what can i do?
-
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
-
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..!?
-
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); }
-
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 } } }
-
You see at the start where I just chopped out the mess and left it with the I2C stuff? Maybe try doing something like that and see what happens.
-
That's also not working...same error..!!
-
Ok, so the code definitely works, and definitely works on an UNO with a PN532 V3 set to I2C mode.
So, logically the only things that could be different in your case are the I2C wiring and the I2C mode setting on the board you have.
Double check that your board is set to function in I2C mode, then double check your wires, maybe try swapping the two data wires around to see if that helps. -
No change..still no success....same error
-
Do you think you could take a picture of your setup?
-
-
Ah, there's your problem - it's not set to I2C mode.
See the little bank of two physical switches right near the I2C connection points? switch 1 needs to be in the UP position for on.
-
How'd you go, @shagun_8 ? Did that work for you?
-
@Lokki Thanks for your help...now its working
-
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?