Why is there no function findCard() in the class RFID?MF522-AN RFID Reader/Writer and Arduino issuesRFID communication protocol programmingRC 522 RFID Error arduinoArduino RFID (Wiegand) Continuous readinghow can i make this RFID module workFTP client on ethernet shield arduinoRFID-RC522 not reading cardRFID-RC522 on Arduino LeonardoHow to stop multiple reads of an RFID card
Is it better to merge "often" or only after completion do a big merge of feature branches?
How can I calculate the cost of Skyss bus tickets
Do Dragonborns get unarmored defense?
Does Impedance Matching Imply any Practical RF Transmitter Must Waste >=50% of Energy?
Why do people say "I am broke" instead of "I am broken"?
Found old paper shares of Motorola Inc that has since been broken up
Is there a way to shorten this while condition?
Finding number of days per ID in table using ArcPy?
What is the best word describing the nature of expiring in a short amount of time, connoting "losing public attention"?
How am I supposed to put out fires?
What's the 1 inch size square knob sticking out of wall?
How did pilots avoid thunderstorms and related weather before “reliable” airborne weather radar was introduced on airliners?
Company requiring me to let them review research from before I was hired
How to run a substitute command on only a certain part of the line
How can I indicate that what I'm saying is not sarcastic online?
Why did computer video outputs go from digital to analog, then back to digital?
Are stackless C++20 coroutines a problem?
As a DM of a 4-player group, would it be appropriate for me to run a private 1-on-1 session so that one PC can act secretly?
RC differentiator giving a higher output amplitude than input amplitude
Xcode 10.3 Installation
Is an easily guessed plot twist a good plot twist?
Is the apartment I want to rent a scam?
Bounded Torsion, without Mazur’s Theorem
Are there any English words pronounced with sounds/syllables that aren't part of the spelling?
Why is there no function findCard() in the class RFID?
MF522-AN RFID Reader/Writer and Arduino issuesRFID communication protocol programmingRC 522 RFID Error arduinoArduino RFID (Wiegand) Continuous readinghow can i make this RFID module workFTP client on ethernet shield arduinoRFID-RC522 not reading cardRFID-RC522 on Arduino LeonardoHow to stop multiple reads of an RFID card
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am using RFID-RC522 to read a card with RFID already installed in the arduino, but when using function findCard() in the class RFID, I get an error:
'class RFID' has no member named 'findCard'
I opened the address where RFID.zip exists in my computer(I installed it by downloading a zip file and add it in arduino). I unzipped it and found that there is no function named "findCard".
Then there are two possibilities: my code is error, or RFID that I downloaded is error.
But I checked my code again, it is as same as what has been written in my book. And I searched in the internet to download a second "RFID.zip" from a different place, which, I later found, was as same as what I downloaded first.
my code is as follows. Error is in Line 19, where has a function named "findCard". These code also use some other functions in class RFID, but those can all be successfully found in RFID.
#include <SPI.h>
#include <RFID.h>
//D10 - 读卡器CS引脚、D5 - 读卡器RST引脚
RFID rfid(10, 5);
unsigned char status;
unsigned char str[MAX_LEN]; //MAX_LEN为16,数组最大长度
void setup()
Serial.begin(9600);
SPI.begin();
rfid.init(); //初始化
void loop()
//Search card, return card types
if (rfid.findCard(PICC_REQIDL, str) == MI_OK)
Serial.println("Find the card!");
// Show card type
ShowCardType(str);
//防冲突检测,读取卡序列号
if (rfid.anticoll(str) == MI_OK)
Serial.print("The card's number is : ");
//显示卡序列号
for (int i = 0; i < 4; i++)
Serial.print(0x0F & (str[i] >> 4), HEX);
Serial.print(0x0F & str[i], HEX);
Serial.println("");
//选卡(锁定卡片,防止多数读取,去掉本行将连续读卡)
rfid.selectTag(str);
rfid.halt(); //命令卡片进入休眠状态
void ShowCardType(unsigned char * type)
Serial.print("Card type: ");
if (type[0] == 0x04 && type[1] == 0x00)
Serial.println("MFOne-S50");
else if (type[0] == 0x02 && type[1] == 0x00)
Serial.println("MFOne-S70");
else if (type[0] == 0x44 && type[1] == 0x00)
Serial.println("MF-UltraLight");
else if (type[0] == 0x08 && type[1] == 0x00)
Serial.println("MF-Pro");
else if (type[0] == 0x44 && type[1] == 0x03)
Serial.println("MF Desire");
else
Serial.println("Unknown");
RFID.h in RFID.zip are as follows, where there is no function findCard:
/* RFID.h - Library to use ARDUINO RFID MODULE KIT 13.56 MHZ WITH TAGS SPI W AND R BY COOQROBOT.
* Based on code Dr.Leong ( WWW.B2CQSHOP.COM )
* Created by Miguel Balboa (circuitito.com), Jan, 2012.
* 整理者:极客工坊bg1lsy (lsy@sogou.com)
* 整理时间:2013.05.25
*/
#ifndef RFID_h
#define RFID_h
#include <Arduino.h>
#include <SPI.h>
/******************************************************************************
* 定义
******************************************************************************/
#define MAX_LEN 16 // 数组最大长度
//MF522命令字
#define PCD_IDLE 0x00 //无动作,取消当前命令
#define PCD_AUTHENT 0x0E //验证密钥
#define PCD_RECEIVE 0x08 //接收数据
#define PCD_TRANSMIT 0x04 //发送数据
#define PCD_TRANSCEIVE 0x0C //发送并接收数据
#define PCD_RESETPHASE 0x0F //复位
#define PCD_CALCCRC 0x03 //CRC计算
//Mifare_One卡片命令字
#define PICC_REQIDL 0x26 //寻天线区内未进入休眠状态
#define PICC_REQALL 0x52 //寻天线区内全部卡
#define PICC_ANTICOLL 0x93 //防冲撞
#define PICC_SElECTTAG 0x93 //选卡
#define PICC_AUTHENT1A 0x60 //验证A密钥
#define PICC_AUTHENT1B 0x61 //验证B密钥
#define PICC_READ 0x30 //读块
#define PICC_WRITE 0xA0 //写块
#define PICC_DECREMENT 0xC0
#define PICC_INCREMENT 0xC1
#define PICC_RESTORE 0xC2 //调块数据到缓冲区
#define PICC_TRANSFER 0xB0 //保存缓冲区中数据
#define PICC_HALT 0x50 //休眠
//和MF522通讯时返回的错误代码
#define MI_OK 0
#define MI_NOTAGERR 1
#define MI_ERR 2
//------------------MFRC522寄存器---------------
//Page 0:Command and Status
#define Reserved00 0x00
#define CommandReg 0x01
#define CommIEnReg 0x02
#define DivlEnReg 0x03
#define CommIrqReg 0x04
#define DivIrqReg 0x05
#define ErrorReg 0x06
#define Status1Reg 0x07
#define Status2Reg 0x08
#define FIFODataReg 0x09
#define FIFOLevelReg 0x0A
#define WaterLevelReg 0x0B
#define ControlReg 0x0C
#define BitFramingReg 0x0D
#define CollReg 0x0E
#define Reserved01 0x0F
//Page 1:Command
#define Reserved10 0x10
#define ModeReg 0x11
#define TxModeReg 0x12
#define RxModeReg 0x13
#define TxControlReg 0x14
#define TxAutoReg 0x15
#define TxSelReg 0x16
#define RxSelReg 0x17
#define RxThresholdReg 0x18
#define DemodReg 0x19
#define Reserved11 0x1A
#define Reserved12 0x1B
#define MifareReg 0x1C
#define Reserved13 0x1D
#define Reserved14 0x1E
#define SerialSpeedReg 0x1F
//Page 2:CFG
#define Reserved20 0x20
#define CRCResultRegM 0x21
#define CRCResultRegL 0x22
#define Reserved21 0x23
#define ModWidthReg 0x24
#define Reserved22 0x25
#define RFCfgReg 0x26
#define GsNReg 0x27
#define CWGsPReg 0x28
#define ModGsPReg 0x29
#define TModeReg 0x2A
#define TPrescalerReg 0x2B
#define TReloadRegH 0x2C
#define TReloadRegL 0x2D
#define TCounterValueRegH 0x2E
#define TCounterValueRegL 0x2F
//Page 3:TestRegister
#define Reserved30 0x30
#define TestSel1Reg 0x31
#define TestSel2Reg 0x32
#define TestPinEnReg 0x33
#define TestPinValueReg 0x34
#define TestBusReg 0x35
#define AutoTestReg 0x36
#define VersionReg 0x37
#define AnalogTestReg 0x38
#define TestDAC1Reg 0x39
#define TestDAC2Reg 0x3A
#define TestADCReg 0x3B
#define Reserved31 0x3C
#define Reserved32 0x3D
#define Reserved33 0x3E
#define Reserved34 0x3F
//-----------------------------------------------
class RFID
public:
RFID(int chipSelectPin, int NRSTPD);
bool isCard();
bool readCardSerial();
void init();
void reset();
void setBitMask(unsigned char reg, unsigned char mask);
void clearBitMask(unsigned char reg, unsigned char mask);
void antennaOn(void);
void antennaOff(void);
void calculateCRC(unsigned char *pIndata, unsigned char len, unsigned char *pOutData);
void writeMFRC522(unsigned char addr, unsigned char val);
unsigned char readMFRC522(unsigned char addr);
unsigned char MFRC522Request(unsigned char reqMode, unsigned char *TagType);
unsigned char MFRC522ToCard(unsigned char command, unsigned char *sendData, unsigned char sendLen, unsigned char *backData, unsigned int *backLen);
unsigned char anticoll(unsigned char *serNum);
unsigned char auth(unsigned char authMode, unsigned char BlockAddr, unsigned char *Sectorkey, unsigned char *serNum);
unsigned char read(unsigned char blockAddr, unsigned char *recvData);
unsigned char write(unsigned char blockAddr, unsigned char *writeData);
unsigned char selectTag(unsigned char *serNum);
void halt();
unsigned char serNum[5]; // 4字节卡序列号,第5字节为校验字节
private:
int _chipSelectPin;
int _NRSTPD;
;
#endif
arduino rfid
add a comment |
I am using RFID-RC522 to read a card with RFID already installed in the arduino, but when using function findCard() in the class RFID, I get an error:
'class RFID' has no member named 'findCard'
I opened the address where RFID.zip exists in my computer(I installed it by downloading a zip file and add it in arduino). I unzipped it and found that there is no function named "findCard".
Then there are two possibilities: my code is error, or RFID that I downloaded is error.
But I checked my code again, it is as same as what has been written in my book. And I searched in the internet to download a second "RFID.zip" from a different place, which, I later found, was as same as what I downloaded first.
my code is as follows. Error is in Line 19, where has a function named "findCard". These code also use some other functions in class RFID, but those can all be successfully found in RFID.
#include <SPI.h>
#include <RFID.h>
//D10 - 读卡器CS引脚、D5 - 读卡器RST引脚
RFID rfid(10, 5);
unsigned char status;
unsigned char str[MAX_LEN]; //MAX_LEN为16,数组最大长度
void setup()
Serial.begin(9600);
SPI.begin();
rfid.init(); //初始化
void loop()
//Search card, return card types
if (rfid.findCard(PICC_REQIDL, str) == MI_OK)
Serial.println("Find the card!");
// Show card type
ShowCardType(str);
//防冲突检测,读取卡序列号
if (rfid.anticoll(str) == MI_OK)
Serial.print("The card's number is : ");
//显示卡序列号
for (int i = 0; i < 4; i++)
Serial.print(0x0F & (str[i] >> 4), HEX);
Serial.print(0x0F & str[i], HEX);
Serial.println("");
//选卡(锁定卡片,防止多数读取,去掉本行将连续读卡)
rfid.selectTag(str);
rfid.halt(); //命令卡片进入休眠状态
void ShowCardType(unsigned char * type)
Serial.print("Card type: ");
if (type[0] == 0x04 && type[1] == 0x00)
Serial.println("MFOne-S50");
else if (type[0] == 0x02 && type[1] == 0x00)
Serial.println("MFOne-S70");
else if (type[0] == 0x44 && type[1] == 0x00)
Serial.println("MF-UltraLight");
else if (type[0] == 0x08 && type[1] == 0x00)
Serial.println("MF-Pro");
else if (type[0] == 0x44 && type[1] == 0x03)
Serial.println("MF Desire");
else
Serial.println("Unknown");
RFID.h in RFID.zip are as follows, where there is no function findCard:
/* RFID.h - Library to use ARDUINO RFID MODULE KIT 13.56 MHZ WITH TAGS SPI W AND R BY COOQROBOT.
* Based on code Dr.Leong ( WWW.B2CQSHOP.COM )
* Created by Miguel Balboa (circuitito.com), Jan, 2012.
* 整理者:极客工坊bg1lsy (lsy@sogou.com)
* 整理时间:2013.05.25
*/
#ifndef RFID_h
#define RFID_h
#include <Arduino.h>
#include <SPI.h>
/******************************************************************************
* 定义
******************************************************************************/
#define MAX_LEN 16 // 数组最大长度
//MF522命令字
#define PCD_IDLE 0x00 //无动作,取消当前命令
#define PCD_AUTHENT 0x0E //验证密钥
#define PCD_RECEIVE 0x08 //接收数据
#define PCD_TRANSMIT 0x04 //发送数据
#define PCD_TRANSCEIVE 0x0C //发送并接收数据
#define PCD_RESETPHASE 0x0F //复位
#define PCD_CALCCRC 0x03 //CRC计算
//Mifare_One卡片命令字
#define PICC_REQIDL 0x26 //寻天线区内未进入休眠状态
#define PICC_REQALL 0x52 //寻天线区内全部卡
#define PICC_ANTICOLL 0x93 //防冲撞
#define PICC_SElECTTAG 0x93 //选卡
#define PICC_AUTHENT1A 0x60 //验证A密钥
#define PICC_AUTHENT1B 0x61 //验证B密钥
#define PICC_READ 0x30 //读块
#define PICC_WRITE 0xA0 //写块
#define PICC_DECREMENT 0xC0
#define PICC_INCREMENT 0xC1
#define PICC_RESTORE 0xC2 //调块数据到缓冲区
#define PICC_TRANSFER 0xB0 //保存缓冲区中数据
#define PICC_HALT 0x50 //休眠
//和MF522通讯时返回的错误代码
#define MI_OK 0
#define MI_NOTAGERR 1
#define MI_ERR 2
//------------------MFRC522寄存器---------------
//Page 0:Command and Status
#define Reserved00 0x00
#define CommandReg 0x01
#define CommIEnReg 0x02
#define DivlEnReg 0x03
#define CommIrqReg 0x04
#define DivIrqReg 0x05
#define ErrorReg 0x06
#define Status1Reg 0x07
#define Status2Reg 0x08
#define FIFODataReg 0x09
#define FIFOLevelReg 0x0A
#define WaterLevelReg 0x0B
#define ControlReg 0x0C
#define BitFramingReg 0x0D
#define CollReg 0x0E
#define Reserved01 0x0F
//Page 1:Command
#define Reserved10 0x10
#define ModeReg 0x11
#define TxModeReg 0x12
#define RxModeReg 0x13
#define TxControlReg 0x14
#define TxAutoReg 0x15
#define TxSelReg 0x16
#define RxSelReg 0x17
#define RxThresholdReg 0x18
#define DemodReg 0x19
#define Reserved11 0x1A
#define Reserved12 0x1B
#define MifareReg 0x1C
#define Reserved13 0x1D
#define Reserved14 0x1E
#define SerialSpeedReg 0x1F
//Page 2:CFG
#define Reserved20 0x20
#define CRCResultRegM 0x21
#define CRCResultRegL 0x22
#define Reserved21 0x23
#define ModWidthReg 0x24
#define Reserved22 0x25
#define RFCfgReg 0x26
#define GsNReg 0x27
#define CWGsPReg 0x28
#define ModGsPReg 0x29
#define TModeReg 0x2A
#define TPrescalerReg 0x2B
#define TReloadRegH 0x2C
#define TReloadRegL 0x2D
#define TCounterValueRegH 0x2E
#define TCounterValueRegL 0x2F
//Page 3:TestRegister
#define Reserved30 0x30
#define TestSel1Reg 0x31
#define TestSel2Reg 0x32
#define TestPinEnReg 0x33
#define TestPinValueReg 0x34
#define TestBusReg 0x35
#define AutoTestReg 0x36
#define VersionReg 0x37
#define AnalogTestReg 0x38
#define TestDAC1Reg 0x39
#define TestDAC2Reg 0x3A
#define TestADCReg 0x3B
#define Reserved31 0x3C
#define Reserved32 0x3D
#define Reserved33 0x3E
#define Reserved34 0x3F
//-----------------------------------------------
class RFID
public:
RFID(int chipSelectPin, int NRSTPD);
bool isCard();
bool readCardSerial();
void init();
void reset();
void setBitMask(unsigned char reg, unsigned char mask);
void clearBitMask(unsigned char reg, unsigned char mask);
void antennaOn(void);
void antennaOff(void);
void calculateCRC(unsigned char *pIndata, unsigned char len, unsigned char *pOutData);
void writeMFRC522(unsigned char addr, unsigned char val);
unsigned char readMFRC522(unsigned char addr);
unsigned char MFRC522Request(unsigned char reqMode, unsigned char *TagType);
unsigned char MFRC522ToCard(unsigned char command, unsigned char *sendData, unsigned char sendLen, unsigned char *backData, unsigned int *backLen);
unsigned char anticoll(unsigned char *serNum);
unsigned char auth(unsigned char authMode, unsigned char BlockAddr, unsigned char *Sectorkey, unsigned char *serNum);
unsigned char read(unsigned char blockAddr, unsigned char *recvData);
unsigned char write(unsigned char blockAddr, unsigned char *writeData);
unsigned char selectTag(unsigned char *serNum);
void halt();
unsigned char serNum[5]; // 4字节卡序列号,第5字节为校验字节
private:
int _chipSelectPin;
int _NRSTPD;
;
#endif
arduino rfid
1
Just look for a version of that library which is from the same year (or somewhere around) the year that your book was published. With that been said I think this question has nothing to do with programming.
– Ivan Kaloyanov
Mar 26 at 14:18
Really I think you are right, but I just tried all the version from min(1.1) to max (1.4), they are all have the same situation...
– YealonK
Mar 26 at 14:34
add a comment |
I am using RFID-RC522 to read a card with RFID already installed in the arduino, but when using function findCard() in the class RFID, I get an error:
'class RFID' has no member named 'findCard'
I opened the address where RFID.zip exists in my computer(I installed it by downloading a zip file and add it in arduino). I unzipped it and found that there is no function named "findCard".
Then there are two possibilities: my code is error, or RFID that I downloaded is error.
But I checked my code again, it is as same as what has been written in my book. And I searched in the internet to download a second "RFID.zip" from a different place, which, I later found, was as same as what I downloaded first.
my code is as follows. Error is in Line 19, where has a function named "findCard". These code also use some other functions in class RFID, but those can all be successfully found in RFID.
#include <SPI.h>
#include <RFID.h>
//D10 - 读卡器CS引脚、D5 - 读卡器RST引脚
RFID rfid(10, 5);
unsigned char status;
unsigned char str[MAX_LEN]; //MAX_LEN为16,数组最大长度
void setup()
Serial.begin(9600);
SPI.begin();
rfid.init(); //初始化
void loop()
//Search card, return card types
if (rfid.findCard(PICC_REQIDL, str) == MI_OK)
Serial.println("Find the card!");
// Show card type
ShowCardType(str);
//防冲突检测,读取卡序列号
if (rfid.anticoll(str) == MI_OK)
Serial.print("The card's number is : ");
//显示卡序列号
for (int i = 0; i < 4; i++)
Serial.print(0x0F & (str[i] >> 4), HEX);
Serial.print(0x0F & str[i], HEX);
Serial.println("");
//选卡(锁定卡片,防止多数读取,去掉本行将连续读卡)
rfid.selectTag(str);
rfid.halt(); //命令卡片进入休眠状态
void ShowCardType(unsigned char * type)
Serial.print("Card type: ");
if (type[0] == 0x04 && type[1] == 0x00)
Serial.println("MFOne-S50");
else if (type[0] == 0x02 && type[1] == 0x00)
Serial.println("MFOne-S70");
else if (type[0] == 0x44 && type[1] == 0x00)
Serial.println("MF-UltraLight");
else if (type[0] == 0x08 && type[1] == 0x00)
Serial.println("MF-Pro");
else if (type[0] == 0x44 && type[1] == 0x03)
Serial.println("MF Desire");
else
Serial.println("Unknown");
RFID.h in RFID.zip are as follows, where there is no function findCard:
/* RFID.h - Library to use ARDUINO RFID MODULE KIT 13.56 MHZ WITH TAGS SPI W AND R BY COOQROBOT.
* Based on code Dr.Leong ( WWW.B2CQSHOP.COM )
* Created by Miguel Balboa (circuitito.com), Jan, 2012.
* 整理者:极客工坊bg1lsy (lsy@sogou.com)
* 整理时间:2013.05.25
*/
#ifndef RFID_h
#define RFID_h
#include <Arduino.h>
#include <SPI.h>
/******************************************************************************
* 定义
******************************************************************************/
#define MAX_LEN 16 // 数组最大长度
//MF522命令字
#define PCD_IDLE 0x00 //无动作,取消当前命令
#define PCD_AUTHENT 0x0E //验证密钥
#define PCD_RECEIVE 0x08 //接收数据
#define PCD_TRANSMIT 0x04 //发送数据
#define PCD_TRANSCEIVE 0x0C //发送并接收数据
#define PCD_RESETPHASE 0x0F //复位
#define PCD_CALCCRC 0x03 //CRC计算
//Mifare_One卡片命令字
#define PICC_REQIDL 0x26 //寻天线区内未进入休眠状态
#define PICC_REQALL 0x52 //寻天线区内全部卡
#define PICC_ANTICOLL 0x93 //防冲撞
#define PICC_SElECTTAG 0x93 //选卡
#define PICC_AUTHENT1A 0x60 //验证A密钥
#define PICC_AUTHENT1B 0x61 //验证B密钥
#define PICC_READ 0x30 //读块
#define PICC_WRITE 0xA0 //写块
#define PICC_DECREMENT 0xC0
#define PICC_INCREMENT 0xC1
#define PICC_RESTORE 0xC2 //调块数据到缓冲区
#define PICC_TRANSFER 0xB0 //保存缓冲区中数据
#define PICC_HALT 0x50 //休眠
//和MF522通讯时返回的错误代码
#define MI_OK 0
#define MI_NOTAGERR 1
#define MI_ERR 2
//------------------MFRC522寄存器---------------
//Page 0:Command and Status
#define Reserved00 0x00
#define CommandReg 0x01
#define CommIEnReg 0x02
#define DivlEnReg 0x03
#define CommIrqReg 0x04
#define DivIrqReg 0x05
#define ErrorReg 0x06
#define Status1Reg 0x07
#define Status2Reg 0x08
#define FIFODataReg 0x09
#define FIFOLevelReg 0x0A
#define WaterLevelReg 0x0B
#define ControlReg 0x0C
#define BitFramingReg 0x0D
#define CollReg 0x0E
#define Reserved01 0x0F
//Page 1:Command
#define Reserved10 0x10
#define ModeReg 0x11
#define TxModeReg 0x12
#define RxModeReg 0x13
#define TxControlReg 0x14
#define TxAutoReg 0x15
#define TxSelReg 0x16
#define RxSelReg 0x17
#define RxThresholdReg 0x18
#define DemodReg 0x19
#define Reserved11 0x1A
#define Reserved12 0x1B
#define MifareReg 0x1C
#define Reserved13 0x1D
#define Reserved14 0x1E
#define SerialSpeedReg 0x1F
//Page 2:CFG
#define Reserved20 0x20
#define CRCResultRegM 0x21
#define CRCResultRegL 0x22
#define Reserved21 0x23
#define ModWidthReg 0x24
#define Reserved22 0x25
#define RFCfgReg 0x26
#define GsNReg 0x27
#define CWGsPReg 0x28
#define ModGsPReg 0x29
#define TModeReg 0x2A
#define TPrescalerReg 0x2B
#define TReloadRegH 0x2C
#define TReloadRegL 0x2D
#define TCounterValueRegH 0x2E
#define TCounterValueRegL 0x2F
//Page 3:TestRegister
#define Reserved30 0x30
#define TestSel1Reg 0x31
#define TestSel2Reg 0x32
#define TestPinEnReg 0x33
#define TestPinValueReg 0x34
#define TestBusReg 0x35
#define AutoTestReg 0x36
#define VersionReg 0x37
#define AnalogTestReg 0x38
#define TestDAC1Reg 0x39
#define TestDAC2Reg 0x3A
#define TestADCReg 0x3B
#define Reserved31 0x3C
#define Reserved32 0x3D
#define Reserved33 0x3E
#define Reserved34 0x3F
//-----------------------------------------------
class RFID
public:
RFID(int chipSelectPin, int NRSTPD);
bool isCard();
bool readCardSerial();
void init();
void reset();
void setBitMask(unsigned char reg, unsigned char mask);
void clearBitMask(unsigned char reg, unsigned char mask);
void antennaOn(void);
void antennaOff(void);
void calculateCRC(unsigned char *pIndata, unsigned char len, unsigned char *pOutData);
void writeMFRC522(unsigned char addr, unsigned char val);
unsigned char readMFRC522(unsigned char addr);
unsigned char MFRC522Request(unsigned char reqMode, unsigned char *TagType);
unsigned char MFRC522ToCard(unsigned char command, unsigned char *sendData, unsigned char sendLen, unsigned char *backData, unsigned int *backLen);
unsigned char anticoll(unsigned char *serNum);
unsigned char auth(unsigned char authMode, unsigned char BlockAddr, unsigned char *Sectorkey, unsigned char *serNum);
unsigned char read(unsigned char blockAddr, unsigned char *recvData);
unsigned char write(unsigned char blockAddr, unsigned char *writeData);
unsigned char selectTag(unsigned char *serNum);
void halt();
unsigned char serNum[5]; // 4字节卡序列号,第5字节为校验字节
private:
int _chipSelectPin;
int _NRSTPD;
;
#endif
arduino rfid
I am using RFID-RC522 to read a card with RFID already installed in the arduino, but when using function findCard() in the class RFID, I get an error:
'class RFID' has no member named 'findCard'
I opened the address where RFID.zip exists in my computer(I installed it by downloading a zip file and add it in arduino). I unzipped it and found that there is no function named "findCard".
Then there are two possibilities: my code is error, or RFID that I downloaded is error.
But I checked my code again, it is as same as what has been written in my book. And I searched in the internet to download a second "RFID.zip" from a different place, which, I later found, was as same as what I downloaded first.
my code is as follows. Error is in Line 19, where has a function named "findCard". These code also use some other functions in class RFID, but those can all be successfully found in RFID.
#include <SPI.h>
#include <RFID.h>
//D10 - 读卡器CS引脚、D5 - 读卡器RST引脚
RFID rfid(10, 5);
unsigned char status;
unsigned char str[MAX_LEN]; //MAX_LEN为16,数组最大长度
void setup()
Serial.begin(9600);
SPI.begin();
rfid.init(); //初始化
void loop()
//Search card, return card types
if (rfid.findCard(PICC_REQIDL, str) == MI_OK)
Serial.println("Find the card!");
// Show card type
ShowCardType(str);
//防冲突检测,读取卡序列号
if (rfid.anticoll(str) == MI_OK)
Serial.print("The card's number is : ");
//显示卡序列号
for (int i = 0; i < 4; i++)
Serial.print(0x0F & (str[i] >> 4), HEX);
Serial.print(0x0F & str[i], HEX);
Serial.println("");
//选卡(锁定卡片,防止多数读取,去掉本行将连续读卡)
rfid.selectTag(str);
rfid.halt(); //命令卡片进入休眠状态
void ShowCardType(unsigned char * type)
Serial.print("Card type: ");
if (type[0] == 0x04 && type[1] == 0x00)
Serial.println("MFOne-S50");
else if (type[0] == 0x02 && type[1] == 0x00)
Serial.println("MFOne-S70");
else if (type[0] == 0x44 && type[1] == 0x00)
Serial.println("MF-UltraLight");
else if (type[0] == 0x08 && type[1] == 0x00)
Serial.println("MF-Pro");
else if (type[0] == 0x44 && type[1] == 0x03)
Serial.println("MF Desire");
else
Serial.println("Unknown");
RFID.h in RFID.zip are as follows, where there is no function findCard:
/* RFID.h - Library to use ARDUINO RFID MODULE KIT 13.56 MHZ WITH TAGS SPI W AND R BY COOQROBOT.
* Based on code Dr.Leong ( WWW.B2CQSHOP.COM )
* Created by Miguel Balboa (circuitito.com), Jan, 2012.
* 整理者:极客工坊bg1lsy (lsy@sogou.com)
* 整理时间:2013.05.25
*/
#ifndef RFID_h
#define RFID_h
#include <Arduino.h>
#include <SPI.h>
/******************************************************************************
* 定义
******************************************************************************/
#define MAX_LEN 16 // 数组最大长度
//MF522命令字
#define PCD_IDLE 0x00 //无动作,取消当前命令
#define PCD_AUTHENT 0x0E //验证密钥
#define PCD_RECEIVE 0x08 //接收数据
#define PCD_TRANSMIT 0x04 //发送数据
#define PCD_TRANSCEIVE 0x0C //发送并接收数据
#define PCD_RESETPHASE 0x0F //复位
#define PCD_CALCCRC 0x03 //CRC计算
//Mifare_One卡片命令字
#define PICC_REQIDL 0x26 //寻天线区内未进入休眠状态
#define PICC_REQALL 0x52 //寻天线区内全部卡
#define PICC_ANTICOLL 0x93 //防冲撞
#define PICC_SElECTTAG 0x93 //选卡
#define PICC_AUTHENT1A 0x60 //验证A密钥
#define PICC_AUTHENT1B 0x61 //验证B密钥
#define PICC_READ 0x30 //读块
#define PICC_WRITE 0xA0 //写块
#define PICC_DECREMENT 0xC0
#define PICC_INCREMENT 0xC1
#define PICC_RESTORE 0xC2 //调块数据到缓冲区
#define PICC_TRANSFER 0xB0 //保存缓冲区中数据
#define PICC_HALT 0x50 //休眠
//和MF522通讯时返回的错误代码
#define MI_OK 0
#define MI_NOTAGERR 1
#define MI_ERR 2
//------------------MFRC522寄存器---------------
//Page 0:Command and Status
#define Reserved00 0x00
#define CommandReg 0x01
#define CommIEnReg 0x02
#define DivlEnReg 0x03
#define CommIrqReg 0x04
#define DivIrqReg 0x05
#define ErrorReg 0x06
#define Status1Reg 0x07
#define Status2Reg 0x08
#define FIFODataReg 0x09
#define FIFOLevelReg 0x0A
#define WaterLevelReg 0x0B
#define ControlReg 0x0C
#define BitFramingReg 0x0D
#define CollReg 0x0E
#define Reserved01 0x0F
//Page 1:Command
#define Reserved10 0x10
#define ModeReg 0x11
#define TxModeReg 0x12
#define RxModeReg 0x13
#define TxControlReg 0x14
#define TxAutoReg 0x15
#define TxSelReg 0x16
#define RxSelReg 0x17
#define RxThresholdReg 0x18
#define DemodReg 0x19
#define Reserved11 0x1A
#define Reserved12 0x1B
#define MifareReg 0x1C
#define Reserved13 0x1D
#define Reserved14 0x1E
#define SerialSpeedReg 0x1F
//Page 2:CFG
#define Reserved20 0x20
#define CRCResultRegM 0x21
#define CRCResultRegL 0x22
#define Reserved21 0x23
#define ModWidthReg 0x24
#define Reserved22 0x25
#define RFCfgReg 0x26
#define GsNReg 0x27
#define CWGsPReg 0x28
#define ModGsPReg 0x29
#define TModeReg 0x2A
#define TPrescalerReg 0x2B
#define TReloadRegH 0x2C
#define TReloadRegL 0x2D
#define TCounterValueRegH 0x2E
#define TCounterValueRegL 0x2F
//Page 3:TestRegister
#define Reserved30 0x30
#define TestSel1Reg 0x31
#define TestSel2Reg 0x32
#define TestPinEnReg 0x33
#define TestPinValueReg 0x34
#define TestBusReg 0x35
#define AutoTestReg 0x36
#define VersionReg 0x37
#define AnalogTestReg 0x38
#define TestDAC1Reg 0x39
#define TestDAC2Reg 0x3A
#define TestADCReg 0x3B
#define Reserved31 0x3C
#define Reserved32 0x3D
#define Reserved33 0x3E
#define Reserved34 0x3F
//-----------------------------------------------
class RFID
public:
RFID(int chipSelectPin, int NRSTPD);
bool isCard();
bool readCardSerial();
void init();
void reset();
void setBitMask(unsigned char reg, unsigned char mask);
void clearBitMask(unsigned char reg, unsigned char mask);
void antennaOn(void);
void antennaOff(void);
void calculateCRC(unsigned char *pIndata, unsigned char len, unsigned char *pOutData);
void writeMFRC522(unsigned char addr, unsigned char val);
unsigned char readMFRC522(unsigned char addr);
unsigned char MFRC522Request(unsigned char reqMode, unsigned char *TagType);
unsigned char MFRC522ToCard(unsigned char command, unsigned char *sendData, unsigned char sendLen, unsigned char *backData, unsigned int *backLen);
unsigned char anticoll(unsigned char *serNum);
unsigned char auth(unsigned char authMode, unsigned char BlockAddr, unsigned char *Sectorkey, unsigned char *serNum);
unsigned char read(unsigned char blockAddr, unsigned char *recvData);
unsigned char write(unsigned char blockAddr, unsigned char *writeData);
unsigned char selectTag(unsigned char *serNum);
void halt();
unsigned char serNum[5]; // 4字节卡序列号,第5字节为校验字节
private:
int _chipSelectPin;
int _NRSTPD;
;
#endif
arduino rfid
arduino rfid
asked Mar 26 at 14:10
YealonKYealonK
32 bronze badges
32 bronze badges
1
Just look for a version of that library which is from the same year (or somewhere around) the year that your book was published. With that been said I think this question has nothing to do with programming.
– Ivan Kaloyanov
Mar 26 at 14:18
Really I think you are right, but I just tried all the version from min(1.1) to max (1.4), they are all have the same situation...
– YealonK
Mar 26 at 14:34
add a comment |
1
Just look for a version of that library which is from the same year (or somewhere around) the year that your book was published. With that been said I think this question has nothing to do with programming.
– Ivan Kaloyanov
Mar 26 at 14:18
Really I think you are right, but I just tried all the version from min(1.1) to max (1.4), they are all have the same situation...
– YealonK
Mar 26 at 14:34
1
1
Just look for a version of that library which is from the same year (or somewhere around) the year that your book was published. With that been said I think this question has nothing to do with programming.
– Ivan Kaloyanov
Mar 26 at 14:18
Just look for a version of that library which is from the same year (or somewhere around) the year that your book was published. With that been said I think this question has nothing to do with programming.
– Ivan Kaloyanov
Mar 26 at 14:18
Really I think you are right, but I just tried all the version from min(1.1) to max (1.4), they are all have the same situation...
– YealonK
Mar 26 at 14:34
Really I think you are right, but I just tried all the version from min(1.1) to max (1.4), they are all have the same situation...
– YealonK
Mar 26 at 14:34
add a comment |
1 Answer
1
active
oldest
votes
If you want to use the RC522 I suggest you use the library offered in the Arduino IDE.
Click Sketch -> Include Library -> Manage Libraries
Search for 522 and install the library you find. This library is up-to-date, very well tested and specifically written for your RFID-Reader and should support the full feature set of that device.
As Ivan pointed out the library you're using is from 2013 and most likely outdated.
I tried to use the library offered in the Arduino IDE, but class RFID there are all called MFRC522. Now I am using that library and have changed my code (I found another codes using class MFRC522 instead of RFID), and then there is no error. Thank you very very much.
– YealonK
Mar 27 at 3:14
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55359233%2fwhy-is-there-no-function-findcard-in-the-class-rfid%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you want to use the RC522 I suggest you use the library offered in the Arduino IDE.
Click Sketch -> Include Library -> Manage Libraries
Search for 522 and install the library you find. This library is up-to-date, very well tested and specifically written for your RFID-Reader and should support the full feature set of that device.
As Ivan pointed out the library you're using is from 2013 and most likely outdated.
I tried to use the library offered in the Arduino IDE, but class RFID there are all called MFRC522. Now I am using that library and have changed my code (I found another codes using class MFRC522 instead of RFID), and then there is no error. Thank you very very much.
– YealonK
Mar 27 at 3:14
add a comment |
If you want to use the RC522 I suggest you use the library offered in the Arduino IDE.
Click Sketch -> Include Library -> Manage Libraries
Search for 522 and install the library you find. This library is up-to-date, very well tested and specifically written for your RFID-Reader and should support the full feature set of that device.
As Ivan pointed out the library you're using is from 2013 and most likely outdated.
I tried to use the library offered in the Arduino IDE, but class RFID there are all called MFRC522. Now I am using that library and have changed my code (I found another codes using class MFRC522 instead of RFID), and then there is no error. Thank you very very much.
– YealonK
Mar 27 at 3:14
add a comment |
If you want to use the RC522 I suggest you use the library offered in the Arduino IDE.
Click Sketch -> Include Library -> Manage Libraries
Search for 522 and install the library you find. This library is up-to-date, very well tested and specifically written for your RFID-Reader and should support the full feature set of that device.
As Ivan pointed out the library you're using is from 2013 and most likely outdated.
If you want to use the RC522 I suggest you use the library offered in the Arduino IDE.
Click Sketch -> Include Library -> Manage Libraries
Search for 522 and install the library you find. This library is up-to-date, very well tested and specifically written for your RFID-Reader and should support the full feature set of that device.
As Ivan pointed out the library you're using is from 2013 and most likely outdated.
answered Mar 26 at 14:35
PigletPiglet
9,1082 gold badges11 silver badges23 bronze badges
9,1082 gold badges11 silver badges23 bronze badges
I tried to use the library offered in the Arduino IDE, but class RFID there are all called MFRC522. Now I am using that library and have changed my code (I found another codes using class MFRC522 instead of RFID), and then there is no error. Thank you very very much.
– YealonK
Mar 27 at 3:14
add a comment |
I tried to use the library offered in the Arduino IDE, but class RFID there are all called MFRC522. Now I am using that library and have changed my code (I found another codes using class MFRC522 instead of RFID), and then there is no error. Thank you very very much.
– YealonK
Mar 27 at 3:14
I tried to use the library offered in the Arduino IDE, but class RFID there are all called MFRC522. Now I am using that library and have changed my code (I found another codes using class MFRC522 instead of RFID), and then there is no error. Thank you very very much.
– YealonK
Mar 27 at 3:14
I tried to use the library offered in the Arduino IDE, but class RFID there are all called MFRC522. Now I am using that library and have changed my code (I found another codes using class MFRC522 instead of RFID), and then there is no error. Thank you very very much.
– YealonK
Mar 27 at 3:14
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55359233%2fwhy-is-there-no-function-findcard-in-the-class-rfid%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Just look for a version of that library which is from the same year (or somewhere around) the year that your book was published. With that been said I think this question has nothing to do with programming.
– Ivan Kaloyanov
Mar 26 at 14:18
Really I think you are right, but I just tried all the version from min(1.1) to max (1.4), they are all have the same situation...
– YealonK
Mar 26 at 14:34