eelcor 18 Posted August 2, 2013 Author Share Posted August 2, 2013 Good to hear! As you can see I also put it in the update message on the first post. By the way, this fix really helps with all SPI related stuff.. Kind regards, Eelco Quote Link to post Share on other sites
D69 3 Posted August 16, 2013 Share Posted August 16, 2013 Just a quick note, Pin1 - SS (SDA on mine) goes to 2.2 and Pin7 - RST goes to 1.3 Looking at your pic it's setup the same as mine. I figured it out from the code before I checked the pic of your setup :shock: Cheers Dean Quote Link to post Share on other sites
D69 3 Posted August 17, 2013 Share Posted August 17, 2013 OK, spent a bit of time on this this evening. Tried knocking together some code to allow hard coding of tag IDs which works OK. Might need to change the for loop though as anything in else just gets repeated, a switch might do the trick but it's late. For anyone interested, here's my code, would appreciate any improvements that could be made, including an scenario where the tag's not recognized as valid. /* Example file for communicating with the NFRC522. The program prints the card data. Created by Eelco Rouw - Originally adapted by Grant Gibson. */ // Pinout // SDA - 2.2 // SCK - 1.5 // Mosi - 1.7 // Miso - 1.6 // IRQ - NC // GND - GND // RST - 1.3 // VCC - VCC #include <Mfrc522.h> // the sensor communicates using SPI, so include the library: #include <SPI.h> int chipSelectPin = 10; int NRSTDP = 5; int ledpin1 = 3; int ledpin2 = 6; int cardint = 5; Mfrc522 Mfrc522(chipSelectPin,NRSTDP); unsigned char serNum[5]; unsigned char sectorKey[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; unsigned char readData[16]; void setup() { Serial.begin(9600); // RFID reader SOUT pin connected to Serial RX pin at 2400bps // Start the SPI library: SPI.begin(); // Initialize the Card Reader digitalWrite(chipSelectPin, LOW); pinMode(RED_LED, OUTPUT); pinMode(ledpin1, OUTPUT); pinMode(ledpin2, OUTPUT); Mfrc522.Init(); } void loop() { unsigned char i,tmp; unsigned char status; unsigned char str[MAX_LEN]; unsigned char RC_size; unsigned char blockAddr; //String mynum = ""; String mycardno; char* myarray[2][5]={ //Array of tags and related names, tag numbers copied from serial console after 1s {"205928944228","1251291514471","7748944415","157172894468","611918944247"}, {"Dad","Mum","Baby","Dog","Cat"} }; status = Mfrc522.Request(PICC_REQIDL, str); if (status == MI_OK) { Serial.println("Card detected"); Serial.print(str[0],BIN); Serial.print(" , "); Serial.print(str[1],BIN); Serial.println(" "); } status = Mfrc522.Anticoll(str); memcpy(serNum, str, 5); if (status == MI_OK) { Serial.println("The card's number is : "); Serial.print(serNum[0], DEC); Serial.print(" , "); Serial.print(serNum[1], DEC); Serial.print(" , "); Serial.print(serNum[2], DEC); Serial.print(" , "); Serial.print(serNum[3], DEC); Serial.print(" , "); Serial.print(serNum[4], DEC); Serial.println(" "); mycardno = String(serNum[0]) += String(serNum[1]) += String(serNum[2]) += String(serNum[3]) += String(serNum[4]); // Appends the content of the serNum array to give a unique card no Serial.println(mycardno); Mfrc522.SelectTag(serNum); status = Mfrc522.Auth(PICC_AUTHENT1A,1,sectorKey,serNum); if (status == MI_OK) { Serial.println("Authenticated...\r\n"); } else { Serial.println("Error authenticating...\r\n"); } status = Mfrc522.ReadBlock(1, readData); if (status == MI_OK) { for(i=0; i<16; i++) { Serial.write(readData[i]); delay(10); } } else { Serial.println("Error reading."); } int i; for(i = 0; i < 5; i = i + 1) { if (mycardno == myarray[0][i]) { Serial.print("Hello "); Serial.println(myarray[1][i]); // Should Print out name matching tag } /*else { Serial.println("Bugger Off"); }*/ } delay(1000); Mfrc522.Init(); } //Serial.println(" "); Mfrc522.Halt(); } Quote Link to post Share on other sites
traxman 23 Posted August 22, 2013 Share Posted August 22, 2013 Today I got RF522 module, works fine with Energia library - THANKS. What do You think about small pcb module RFID-Door Control (MSP430G2+Relay+Buzzer+LED) connected directly to RC522 board? Quote Link to post Share on other sites
eelcor 18 Posted August 25, 2013 Author Share Posted August 25, 2013 I think that would be a great idea. You should check the possibilities with the available smart cards, you can do some really neat stuff with it! I could envision you should add a small serial eeprom to the board as you can store an access table and do something with challenge/handshake. I haven't tried the above but it would help to make a solid door mechanism. Kind regards, Eelco Quote Link to post Share on other sites
D69 3 Posted August 25, 2013 Share Posted August 25, 2013 Today I got RF522 module, works fine with Energia library - THANKS. What do You think about small pcb module RFID-Door Control (MSP430G2+Relay+Buzzer+LED) connected directly to RC522 board? Sounds similar to what I'm working on, adding a uln2003 to help with the mixed power of the leds and relays. Serial eeprom sounds like a good idea too, I was going to try with an SD card but it would be overkill! Quote Link to post Share on other sites
traxman 23 Posted August 26, 2013 Share Posted August 26, 2013 I prefer discrete Mosfet or BJT than ULN. Sometimes I had problem with latching output (on chip harmfull thyristor). Quote Link to post Share on other sites
D69 3 Posted August 30, 2013 Share Posted August 30, 2013 That looks good Traxman What's the idea behind your MOSI/MISO setup, I've not seen it done like that before? The ULN with relay combo is working fine at the minute, are there any equivalents arrays with FETs? Just migrated my setup to a breadboard and it works perfectly, ready to stick it onto protoboard now. Quote Link to post Share on other sites
traxman 23 Posted August 30, 2013 Share Posted August 30, 2013 What's the idea behind your MOSI/MISO setup, I've not seen it done like that before? Split SPI signals for 452/553 cpu. Quote Link to post Share on other sites
LIN 0 Posted December 17, 2013 Share Posted December 17, 2013 Could you give me your RFID-RC522 on lanchpad source codes ? Because I can't run your source code Quote Link to post Share on other sites
Promila 0 Posted January 7, 2014 Share Posted January 7, 2014 Could you give me your RFID-RC522 on lanchpad source codes ? Because I can't run your source code I would like to have the same too to try out. Thanks Quote Link to post Share on other sites
D69 3 Posted February 1, 2014 Share Posted February 1, 2014 My code is on the previous page, what doesn't run? Quote Link to post Share on other sites
phaseform 3 Posted February 6, 2014 Share Posted February 6, 2014 I have a whole bunch of problems getting my Stellaris to play nice with my ebay 522 reader... EDIT: got it here So far I cant get the serial monitor to send anything back to the computer. I've tried changing the baud rate - 9600 and 2400. also, I'm confused at to the pin connection, I've tried:// SDA on Stellaris pinmap SDA(0) is PB_3// SCK on Stellaris pinmap SCK(0) is PA_2// Mosi on Stellaris pinmap MOSI(0) is PA_5// Miso on Stellaris pinmap MISO(0) is PA_4// IRQ - not connected// GND - GND// RST - 1.3 on 430 refers to PUSH2; on Stellaris = PF_0... not sure bout this// VCC - 3.3v I tried:SPI.setModule(0);in the setup and this returned nothing in the serial monitor.. from here I modified the code to send *something* back to the computer over serial.. status = Mfrc522.Request(PICC_REQIDL, str); if (status == MI_OK) { Serial.println("Card detected"); Serial.print(str[0],BIN); Serial.print(" , "); Serial.print(str[1],BIN); Serial.println(" "); } else{ //added this Serial.println("nope"); } and still I'm getting NOTHING back over serial. which confuses me, I thought Id be getting 'nope' on a new line constantly *confused* in the 'working' code, I'm not rly sure what the line int NRSTDP = 5; refers to, seemingly PUSH2, so I tried changing that to 17 to correspond with the stellaris, not sure if this makes any difference. After this I tried changing the pin wiring around to suit the "default" for SPI http://forum.43oh.com/topic/3387-spi-pin-map-for-stellaris-launchpad-lm4f120/ // Pinout// SDA - 2.2 (430 launchpad) -> 10 (stellaris launchpad)// SCK - 1.5 (430) -> PB_4 (stellaris)// Mosi - 1.7 (430) -> PB_7 (stellaris)// Miso - 1.6 (430) -> PB_6 (stellaris)// IRQ - Not connected// GND - GND// RST - 1.3 (430) -> 1.3 refers to PUSH2; PF_0... not sure bout this// VCC - VCC and leaving SPI.setModule(0); out of the code... nothing. I tried putting SPI.setModule(2); in the code..nothing. this is the most recent code, which is basically an amalgamation of the above problems /* Example file for communicating with the NFRC522. The program prints the card data. Created by Eelco Rouw - Originally adapted by Grant Gibson. */ // Pinout // SDA - 2.2 on pinmap SDA(0) is PB_3.. default - PA_7 or maybe 10 // SCK - 1.5 on pinmap SCK(0) is PA_2.. default - PB_4 // Mosi - 1.7 on pinmap MOSI(0) is PA_5.. default (no SPI.setModule) - PB_7 // Miso - 1.6 on pinmap MISO(0) is PA_4.. default - PB_6 // IRQ - NC // GND - GND // RST - 1.3 on pinmap... 1.3 refers to PUSH2; PF_0... not sure bout this // VCC - VCC #include <Mfrc522.h> // the sensor communicates using SPI, so include the library: #include <SPI.h> int chipSelectPin = 10; //SDA on reader (pin 10 is PA_7 on stellaris) although try PB_3 as above instead of 10 int NRSTDP = 17; Mfrc522 Mfrc522(chipSelectPin,NRSTDP); unsigned char serNum[5]; void setup() { Serial.begin(9600); // RFID reader SOUT pin connected to Serial RX pin at 2400bps // Start the SPI library: SPI.setModule(2); // taken from http://forum.43oh.com/topic/3387-spi-pin-map-for-stellaris-launchpad-lm4f120/ SPI.begin(); // Initialize the Card Reader digitalWrite(chipSelectPin, LOW); pinMode(RED_LED, OUTPUT); Mfrc522.Init(); } void loop() { unsigned char i,tmp; unsigned char status; unsigned char str[MAX_LEN]; unsigned char RC_size; unsigned char blockAddr; String mynum = ""; status = Mfrc522.Request(PICC_REQIDL, str); if (status == MI_OK) { Serial.println("Card detected"); Serial.print(str[0],BIN); Serial.print(" , "); Serial.print(str[1],BIN); Serial.println(" "); } else{ Serial.println("Card detected"); } status = Mfrc522.Anticoll(str); memcpy(serNum, str, 5); if (status == MI_OK) { Serial.println("The card's number is : "); Serial.print(serNum[0]); Serial.print(" , "); Serial.print(serNum[1],BIN); Serial.print(" , "); Serial.print(serNum[2],BIN); Serial.print(" , "); Serial.print(serNum[3],BIN); Serial.print(" , "); Serial.print(serNum[4],BIN); Serial.println(" "); // Should really check all pairs, but for now we'll just use the first if(serNum[0] == 29) { Serial.println("Hello Eelco"); digitalWrite(RED_LED, HIGH); delay(1000); digitalWrite(RED_LED, LOW); } delay(1000); } //Serial.println(" "); Mfrc522.Halt(); } So far, no dice. Any help with this would be appreciated! thanks! Quote Link to post Share on other sites
outexceptme 0 Posted March 6, 2014 Share Posted March 6, 2014 Thx 4 sharing~ Quote Link to post Share on other sites
wassimsb 0 Posted March 11, 2014 Share Posted March 11, 2014 im very interessted for the code (RC522 + MSP430) for spi, Therefore I need the code to read/write Mifare classic tags. That Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.