Elechouse PN532 NFC Module V3 for Arduino etc.
-
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.
-
Yeah I reloaded it and loaded in both rings it was reading, as well as the one I sent you...wjich I got the uid from the terminal windownnnwhich means I must be getting the right id
but no go
-
Hello! I'm a Car! Reader Online, Waiting for a valid key UID Value: ..4..B..4C..22..99..3C..814b4c22993c81 UID Value: ..4..B..4C..22..99..3C..814b4c22993c81 UID Value: ..4..32..32..22..99..3C..814323222993c81 UID Value: ..4..32..32..22..99..3C..814323222993c81
Serial.println(ringUid + "\n"); if (ringUid == "42cbfd26f3f81" || ringUid == "814b4c22993c81" || ringUid == "814323222993c81" || ringUid == "xxxxxxxxxxxxxx") { Serial.println("Key accepted!"); }
-
ok poured over this again last night...im positive im missing something, but really no idea what it is...
anyone with some programing experience got any tips on why this wouldnt be working? -
@MarkGabb said in Elechouse PN532 NFC Module V3 for Arduino etc.:
Hello! I'm a Car! Reader Online, Waiting for a valid key UID Value: ..4..B..4C..22..99..3C..814b4c22993c81 UID Value: ..4..B..4C..22..99..3C..814b4c22993c81 UID Value: ..4..32..32..22..99..3C..814323222993c81 UID Value: ..4..32..32..22..99..3C..814323222993c81
Serial.println(ringUid + "\n"); if (ringUid == "42cbfd26f3f81" || ringUid == "814b4c22993c81" || ringUid == "814323222993c81" || ringUid == "xxxxxxxxxxxxxx") { Serial.println("Key accepted!"); }
heh. I can see one thing wrong at least. 4b4c22993c81 not 814b4c22993c81 and 4323222993c81 not 814323222993c81
-
If that doesn't work I'd recommend installing nxp taginfo on an android device, read your ring and take the UID from the "tech" tab. There are zeros that may be necessary. eg. 04 0B 4C 22 99 3C 81
Don't forget to kill the process before locking your device if you're using the nfc ring unlock app. -
@Lokki spot on. i read the tag reading the wrong way around
im guessing it wont pass to next section until i have the circuits completed...
i remove the part when it checks for handbrakes and have just set it to 0 permanantlyit wont say engine cranking, but im pretty sure that because nothing other than nfc reader is connected to it
do you know anyone who has done an eagle for this??
i think this is worthy of sending the board out for proper creation -
MrStein has his own design of this, with different code. Mine is basically just hacked together in my head, as per the sketch output pins. It's possibly a bit too "organic" for me to go back and actually diagram. I'd have to start again, pretty much. In my other thread "quick and dirty vehicle start/entry sketch" I've written down what I've done, which parts were selected and why. That'd be a good start, but I'd go for larger relays if I were doing it again in an older car. Just remember, it's got to be a latching relay for the car power and a momentary relay for the starter motor.
I'll have to set up the basic board again for testing, I expanded it, added a screen, did a few other of this and that and then removed it to sell the car. I'm pretty certain it cycled through properly without anything else being hooked up though, I've got a youtube video somewhere showing that happening with an LED.Just comment out anything that you're not using, like the handbrake part.