Elechouse PN532 NFC Module V3 for Arduino etc.
-
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?
-
No worries at all, dude. I like it best when things work!
TBH I've only really used my gear with mifare classics and NTAG based tags/fobs/rings/etc. (I've never used a Topaz in any form.)From the manual it says this:
RFID reader/writer mode support
Mifare 1k, 4k, Ultralight, and DesFire cards
ISO/IEC 14443-4 cards such as CD97BX, CD light, DesFire, P5CN072 (SMX)
Innovision Jewel cards such as IRT5001 card
FeliCa cards such as RCS_860 and RCS_854I have found though that your mileage may vary as to where and how well you read some things. You might need to play around with it a bit to get best results.
-
When I try to write on the mifare classic......the serial monitor shows....block authentication failed for 4..what to do?
CODE:
#include <Wire.h> #include <PN532_I2C.h> #include <PN532.h> // The following files are included in the libraries Installed #include <NfcAdapter.h> PN532_I2C pn532_i2c(Wire); NfcAdapter nfc = NfcAdapter(pn532_i2c); // Indicates the Shield you are using void setup() { Serial.begin(9600); Serial.println("NFC Tag Writer"); // Serial Monitor Message nfc.begin(); } void loop() { Serial.println("\nPlace an NFC Tag that you want to Record these Messages on!"); // Command for the Serial Monitor if (nfc.tagPresent()) { NdefMessage message = NdefMessage(); message.addTextRecord("Abc"); // Text Message you want to Record boolean success = nfc.write(message); if (success) { Serial.println("Good Job, now read it with your phone!"); // if it works you will see this message } else { Serial.println("Write failed"); // If the the rewrite failed you will see this message } } delay(10000); } Yes you can wrap the code with 3 backticks.
-
It says "the tag is not NDEF Formatted"....so should it be NDEF formatted to use it with the module?
-
Ah, you may have to look into that - have a read up on the mifare classic data sheet.
-
hey lokki
long time no seeI'm finally got some more free time so I'm back to working out what the hell I'm doing :P
coud I ask with your mr crappy car code...if I'm getting a uid value as follows
..4..2C..BF..D2..6F..3F..8142cbfd26f3f81where does that information need to be put for the code to accept it as one of the valid keys?
-
Howdy again, @MarkGabb
It should look something like this: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 == "42cbfd26f3f81" || ringUid == "xxxxxxxxxxxxxx" || ringUid == "xxxxxxxxxxxxxx" || ringUid == "xxxxxxxxxxxxxx"){ Serial.println("Key accepted!"); } if ((ringUid == "42cbfd26f3f81" || 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 == "42cbfd26f3f81" || 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 == "42cbfd26f3f81" || 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 } } }
If you're not using one of the ringUid bits then just delete it, the sketch can work with only one ring set up or it can work with 12. I had it set up with two rings, front and back, so that myself and the girlfriend could start the car and didn't have to worry about which way the ring was facing.
-
Hmmm this script seems very different to the one I've got loaded.....made some improvments??
-
Ok so ill upload tonight, ive forgotten physical pin mapping
Arduino nanoI know my reader is in a4 and a5 and is correct because the reader is showing in the terminal
-
yeah, I think the one you grabbed a while back would have been seperate cards for on/ignition/off. It was a while back.
Just set the pins however you want them, it's pretty arbitrary. I think from memory the handbrakepin1 basically does nothing, you could chop that out. -
Sorry question wasn't terribly clear... I forget how to actually assign pins. so if I wanted trigger pin1 to be b5 do I just change the 2 to b5?
-
Lol strait back and full of questions
So I've loaded the code and input my keys.... however I don't get any further messages from the board about state it just reads the uid back to be over and over... shouldnt get a message about state from the board?
-
Yeah it should be returning a state like "key accepted" or whatever I've got written in there. Read the uid in however many tags/rings you've got and enter them in, re-load the sketch and see what happens - I may have pasted the uid in wrong.