不要在arduino的串行监视器上显示重复的数据输出



在此代码中,我根据sparkfun(制造(文档和RFID标签检测代码以数组的形式获取TID数据(20字节的160位(,其工作正常并获得RFID标签的输出。

现在我只需要您的指导,如何停止显示已经在 arduino 串行监视器上显示的 RFID 标签 ID。我该怎么办!

Arduino 代码:

/*Reading multiple RFID tags, simultaneously!
TIDs are 20 bytes, 160 bits*/
#include <SoftwareSerial.h> //Used for transmitting
SoftwareSerial softSerial(2, 3); //RX, TX
#include "SparkFun_UHF_RFID_Reader.h" //Library for controlling the M6E Nano module
RFID nano; //Create instance
void setup()
{
Serial.begin(115200);
while (!Serial);
Serial.println();
Serial.println("Initializing...");
if (setupNano(38400) == false) //Configure nano to run at 38400bps
{
Serial.println("Module failed to respond. Please check wiring.");
while (1); //Freeze!
}
nano.setRegion(REGION_NORTHAMERICA); //Set to North America
nano.setReadPower(1000); //10.00 dBm. 
nano.enableDebugging(); //Turns on commands sent to and heard from RFID module
}
void loop()
{
/*Serial.println(F("Get one tag near the reader. Press a key to read unique tag ID."));
while (!Serial.available()); //Wait for user to send a character*/
Serial.read(); //Throw away the user's character
byte response;
byte myTID[20]; //TIDs are 20 bytes
byte tidLength = sizeof(myTID);
//Read unique ID of tag
response = nano.readTID(myTID, tidLength);
if (response == RESPONSE_SUCCESS)
{
Serial.println("TID read!");
Serial.print("TID: [");
for(byte x = 0 ; x < tidLength ; x++)
{
if(myTID[x] < 0x10) Serial.print("0");
Serial.print(myTID[x], HEX);
Serial.print(" ");
}
Serial.println("]");
}
else
Serial.println("Failed read");
}
//Gracefully handles a reader that is already configured and already reading continuously
//Because Stream does not have a .begin() we have to do this outside the library
boolean setupNano(long baudRate)
{
nano.begin(softSerial); //Tell the library to communicate over software serial port
softSerial.begin(baudRate); //For this test, assume module is already at our desired baud rate
while(!softSerial); //Wait for port to open
while(softSerial.available()) softSerial.read();
nano.getVersion();
if (nano.msg[0] == ERROR_WRONG_OPCODE_RESPONSE)
{
//This happens if the baud rate is correct but the module is doing a ccontinuous read
nano.stopReading();
Serial.println(F("Module continuously reading. Asking it to stop..."));
delay(1500);
}
else
{
//The module did not respond so assume it's just been powered on and communicating at 115200bps
softSerial.begin(115200); //Start software serial at 115200
nano.setBaud(baudRate); //Tell the module to go to the chosen baud rate. Ignore the response msg
softSerial.begin(baudRate); //Start the software serial port, this time at user's chosen baud rate
}
//Test the connection
nano.getVersion();
if (nano.msg[0] != ALL_GOOD) return (false); //Something is not right
//The M6E has these settings no matter what
nano.setTagProtocol(); //Set protocol to GEN2
nano.setAntennaPort(); //Set TX/RX antenna ports to 1
return (true); //We are ready to rock
}

这就是您应该在应用程序中执行的操作。

RFID阅读器和RFID标签的基本规格是在请求读取时通知读取范围内的所有标签。

请将以下程序/功能合并到应用程序中。

  1. 从RFID阅读器通知的标签数据被存储为每个读数。
  2. 到下一次读数时,将这次通知的标签数据与先前通知的数据进行比较。
  3. 不显示已接收的标签数据。

请确定记录标签数据的间隔和次数,并根据您的规格和要求进行比较。

对于符合ISO/IEC 18000-63的标签,在读取请求时指定名为S标志的参数,无法在一定时间内发出重复通知。
但是,由于详细行为取决于各个标记的规格和操作环境,因此不建议使用 S 标志。

最新更新