Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arduino NFC模块(DFRobot)未读取WHIZTAG_Arduino_Tags_Nfc_Arduino Uno_Uart - Fatal编程技术网

Arduino NFC模块(DFRobot)未读取WHIZTAG

Arduino NFC模块(DFRobot)未读取WHIZTAG,arduino,tags,nfc,arduino-uno,uart,Arduino,Tags,Nfc,Arduino Uno,Uart,我买了,我正在使用他们的示例程序进行一些更改,因为我只想读取标签的UID。它与随附的标签配合使用效果很好,但它无法识别我的任何产品(其中包含Topaz 512芯片) 有人知道我该怎么解决这个问题吗 这是我的代码: #include <SoftwareSerial.h> /* # Editor : Adrian # Date : 2013.04.18 # Ver : 0.1 # Product: NFC Module for Arduino # SKU :

我买了,我正在使用他们的示例程序进行一些更改,因为我只想读取标签的UID。它与随附的标签配合使用效果很好,但它无法识别我的任何产品(其中包含Topaz 512芯片)

有人知道我该怎么解决这个问题吗

这是我的代码:

#include <SoftwareSerial.h>
/* 

 # Editor : Adrian
 # Date   : 2013.04.18
 # Ver    : 0.1
 # Product: NFC Module for Arduino
 # SKU    : DFR0231

 # Description:     
 # When the a card close to the device , the PC will receive the data 
 # Connect the NFC Card's TXD, RXD, GND, +3.3V to Nano's D0RX, D1TX, GND, +3.3V
 # Or connect the NFC Card's TXD, RXD, GND, +5V to Nano's D0RX, D1TX, GND, +5V


 PN532 reads the tag by Arduino mega/Leonardo
 command list:

 #wake up reader
 send: 55 55 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff 03 fd d4 14 01 17 00
 return: 00 00 FF 00 FF 00 00 00 FF 02 FE D5 15 16 00

 #get firmware
 send: 00 00 FF 02 FE D4 02 2A 00
 return: 00 00 FF 00 FF 00 00 00 FF 06 FA D5 03 32 01 06 07 E8 00

 #read the tag
 send: 00 00 FF 04 FC D4 4A 01 00 E1 00
 return: 00 00 FF 00 FF 00 00 00 FF 0C F4 D5 4B 01 01 00 04 08 04 XX XX XX XX 5A 00
 XX is tag.

 */

 //************* start **************

const unsigned char wake[24]={
  0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x03, 0xfd, 0xd4, 0x14, 0x01, 0x17, 0x00};//wake up NFC module
const unsigned char firmware[9]={
  0x00, 0x00, 0xFF, 0x02, 0xFE, 0xD4, 0x02, 0x2A, 0x00};//
const unsigned char tag[11]={
  0x00, 0x00, 0xFF, 0x04, 0xFC, 0xD4, 0x4A, 0x01, 0x00, 0xE1, 0x00};//detecting tag command
const unsigned char std_ACK[25] = {
  0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x0C, \
0xF4, 0xD5, 0x4B, 0x01, 0x01, 0x00, 0x04, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x4b, 0x00};
char old_id[5];

unsigned char receive_ACK[25];//Command receiving buffer
//int inByte = 0;               //incoming serial byte buffer

#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#define print1Byte(args) mySerial.write(args)
#define print1lnByte(args)  mySerial.write(args),mySerial.println()
#else
#include "WProgram.h"
#define print1Byte(args) mySerial.print(args,BYTE)
#define print1lnByte(args)  mySerial.println(args,BYTE)
#endif

SoftwareSerial mySerial(10, 11); // RX, TX
unsigned char myUID[12] = "70 89 7E 43";

void setup()
{
  Serial.begin(9600);   // open serial with PC
  mySerial.begin(115200);    //open mySerial with device
  wake_card();
  delay(200);
  Serial.println("Scanning..."); 

}

void loop()
{
  send_tag(); 
  read_ACK(25);
  delay(100);
      if (test_ACK ()) {
        copy_id ();
        displayuid ();
         delay (10000);
       }

    }


void copy_id (void) 
{//save old id
  int ai, oi;
  for (oi=0, ai=19; oi<5; oi++,ai++) {
    old_id[oi] = receive_ACK[ai];
  }
}

int test_ACK (void) 
{// return true if receive_ACK accord with std_ACK
  int i;
  for (i=0; i<19; i++) {
    if (receive_ACK[i] != std_ACK[i])
      return 0;
  }
  return 1;
}


void send_id (void) 
{//send id to PC
  int i;
  Serial.print ("ID: ");
  for (i=19; i<= 23; i++) {
    Serial.print (receive_ACK[i], HEX);
    Serial.print (" ");
  }
  Serial.println ();
}


void UART1_Send_Byte(unsigned char command_data)
{//send byte to device
  print1Byte(command_data);
#if defined(ARDUINO) && ARDUINO >= 100
  mySerial.flush();// complete the transmission of outgoing serial data 
#endif
} 


void UART_Send_Byte(unsigned char command_data)
{//send byte to PC
  Serial.print(command_data,HEX);
  Serial.print(" ");
} 


void read_ACK(unsigned char temp)
{//read ACK into receive_ACK[]
  unsigned char i;
  for(i=0;i<temp;i++) {
  receive_ACK[i]= mySerial.read();
  }
}

void wake_card(void)
{//send wake[] to device
  unsigned char i;
  for(i=0;i<24;i++) //send command
  UART1_Send_Byte(wake[i]);
}


void send_tag(void)
{//send tag[] to device
  unsigned char i;
  for(i=0;i<11;i++) //send command
  UART1_Send_Byte(tag[i]);
}


void displayuid(void)
{//send receive_ACK[] to PC
  unsigned char i;
  for(i=0;i<4;i++) //send command
  UART_Send_Byte(old_id[i]);
  Serial.println();
}


//*********** end *************
#包括
/* 
#编辑:阿德里安
#日期:2013.04.18
#版本:0.1
#产品:Arduino的NFC模块
#库存单位:DFR0231
#说明:
#当卡靠近设备时,PC将接收数据
#将NFC卡的TXD、RXD、GND、+3.3V连接至Nano的D0RX、D1TX、GND、+3.3V
#或者将NFC卡的TXD、RXD、GND、+5V连接到Nano的D0RX、D1TX、GND、+5V
PN532读取Arduino mega/Leonardo的标签
命令列表:
#唤醒阅读器
发送:55 55 00 00 00 ff 03 fd d4 14 01 17 00
返回:00 00 FF 00 FF 00 00 FF 02 FE D5 15 16 00
#获取固件
发送:00 FF 02 FE D4 02 2A 00
返回:00 00 FF 00 FF 00 00 FF 06 FA D5 03 32 01 06 07 E8 00
#读标签
发送:00 FF 04 FC D4 4A 01 00 E1 00
返回:00 00 FF 00 FF 00 00 FF 0C F4 D5 4B 01 00 04 08 04 XX XX XX 5A 00
XX是标签。
*/
//*************开始**************
常量无符号字符唤醒[24]={
0x55,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00\
0x00、0x00、0x00、0x00、0x00、0x00、0xff、0x03、0xfd、0xd4、0x14、0x01、0x17、0x00}//唤醒NFC模块
常量无符号字符固件[9]={
0x00,0x00,0xFF,0x02,0xFE,0xD4,0x02,0x2A,0x00}//
常量无符号字符标记[11]={
0x00,0x00,0xFF,0x04,0xFC,0xD4,0x4A,0x01,0x00,0xE1,0x00}//检测标记命令
常量无符号字符标准确认[25]={
0x00,0x00,0xFF,0x00,0xFF,0x00,0x00,0x00,0x00,0xFF,0x0C\
0xF4、0xD5、0x4B、0x01、0x01、0x00、0x04、0x08、0x04、0x00、0x00、0x00、0x00、0x4B、0x00};
charold_id[5];
未签名字符接收确认[25]//命令接收缓冲器
//int-inByte=0//传入串行字节缓冲区
#如果定义(ARDUINO)&&ARDUINO>=100
#包括“Arduino.h”
#定义print1Byte(args)mySerial.write(args)
#定义print1lnByte(args)mySerial.write(args),mySerial.println()
#否则
#包括“WProgram.h”
#定义print1Byte(args)mySerial.print(args,BYTE)
#定义print1lnByte(args)mySerial.println(args,BYTE)
#恩迪夫
软件系列mySerial(10,11);//接收,发送
无符号字符myUID[12]=“70 89 7E 43”;
无效设置()
{
Serial.begin(9600);//用PC打开串口
mySerial.begin(115200);//使用设备打开mySerial
唤醒卡();
延迟(200);
Serial.println(“扫描…”);
}
void循环()
{
发送标签();
阅读确认(25);
延迟(100);
如果(测试确认()){
拷贝id();
displayid();
延迟(10 000);
}
}
作废副本\u id(作废)
{//保存旧id
国际ai,oi;

对于(oi=0,ai=19;oi您的读卡器模块包含NXP PN532 NFC传输模块IC。您当前使用以下命令轮询标签:

tag = { 0x00, 0x00, 0xFF, 0x04, 0xFC, 0xD4, 0x4A, 0x01, 0x00, 0xE1, 0x00};
您可以在中找到更多详细信息

tag = { 0x00, 0x00, 0xFF, 0x04, 0xFC, 0xD4, 0x4A, 0x01, 0x04, 0xDD, 0x00};