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

Don't display repeated data output on serial monitor of 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 reader和RFID标签的基本规格是在请求读取时通知读取范围内的所有标签。

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

  1. 每次读取都会存储从 RFID reader 通知的标签数据。
  2. 下次读取时,将本次通知的标签数据与之前通知的数据进行比较
  3. 不显示已接收的标签数据。

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

在符合ISO/IEC18000-63的标签的情况下,在读取请求时通过指定称为S标志的参数,无法在一定时间内进行重复通知。
但是,由于具体行为取决于各个标签的规范和操作环境,因此不建议使用 S 标志。