READ BOTH EPC AND UID at the same time

I am using an arduino uno wifi rev 2 and can not for the life of me get the UID and EPC to read at the same time. Here is my existing code but it returns a failed to read UID regardless of how I modify it. Any suggestions or assistance would be greatly appreciated.

6:20:55.890 → Failed to read UID

16:20:55.922 → response: [FF] [28] [22] [00] [00] [10] [00] [1B] [01] [FF] [01] [01] [D7] [11] [0E] [01] [28] [00] [00] [02] [D6] [00] [AE] [05] [00] [00] [80] [00] [80] [34] [00] [31] [32] [33] [34] [DD] [D9] [01] [40] [00] [00] [00] [00] [DF] [2B]

16:20:55.955 → EPC Data: 31 32 33 34 DD D9 01 40 00 00 00 00

16:20:56.968 → sendCommand: [FF] [08] [28] [07] [D0] [02] [00] [00] [00] [02] [04] [12] [77]

16:20:56.999 → response: [FF] [28] [22] [00] [00] [10] [00] [1B] [01] [FF] [01] [01] [D7] [11] [0E] [08] [30] [00] [00] [03] [53] [00] [AE] [05] [00] [00] [80] [00] [80] [34] [00] [31] [32] [33] [34] [DD] [D9] [01] [40] [00] [00] [00] [00] [DF] [2B]

16:20:57.031 → Wrong opcode response

16:20:57.064 → Failed to read UID

16:20:57.064 → response: [FF] [28] [22] [00] [00] [10] [00] [1B] [01] [FF] [01] [01] [DF] [11] [0E] [08] [30] [00] [00] [03] [57] [00] [AE] [05] [00] [00] [80] [00] [80] [34] [00] [31] [32] [33] [34] [DD] [D9] [01] [40] [00] [00] [00] [00] [DF] [2B]

16:20:57.096 → EPC Data: 31 32 33 34 DD D9 01 40 00 00 00 00

#include <SoftwareSerial.h>
#include "SparkFun_UHF_RFID_Reader.h"

SoftwareSerial softSerial(2, 3); // RX, TX
RFID nano; // Create instance

void setup()
{
  Serial.begin(115200);
  while (!Serial);

  if (setupNano(38400) == false)
  {
    Serial.println(F("Module failed to respond. Please check wiring."));
    while (1);
  }

  nano.setRegion(REGION_NORTHAMERICA);
  nano.setReadPower(500);

  Serial.println(F("Starting to scan for tags..."));
  nano.startReading(); // Begin scanning for tags

  nano.enableDebugging();
}

void loop()
{
  if (nano.check() == true) // New tag found
  {
    byte responseType = nano.parseResponse();

    if (responseType == RESPONSE_IS_TAGFOUND)
    {
      // Extracting the EPC data of the tag.
      byte tagEPCBytes = nano.getTagEPCBytes();

      Serial.print("EPC Data: ");
      for (byte x = 0; x < tagEPCBytes; x++)
      {
        if (nano.msg[31 + x] < 0x10) Serial.print("0"); // Leading zero
        Serial.print(nano.msg[31 + x], HEX);
        Serial.print(" ");
      }
      Serial.println();

      // We've successfully read the EPC; now, let's try to read the UID.
      byte response;
      byte myUID[8];
      byte uidLength = sizeof(myUID);
  
      // Introduce a short delay before reading the UID to ensure the reader is ready
      delay(1000); // 500 ms delay; adjust as needed for your hardware

      // Now, read unique ID of the tag
      response = nano.readTID(myUID, uidLength);
      if (response == RESPONSE_SUCCESS)
      {
        Serial.println("UID read!");
        Serial.print("UID: [");
        for(byte x = 0 ; x < uidLength ; x++)
        {
          if(myUID[x] < 0x10) Serial.print("0");
          Serial.print(myUID[x], HEX);
          Serial.print(" ");
        }
        Serial.println("]");
      } 
      else 
      {
        Serial.println("Failed to read UID");
      }
    }
    else if (responseType == ERROR_CORRUPT_RESPONSE)
    {
      Serial.println("Bad CRC");
    }
  }
}

// setupNano function remains the same as in your previous example
boolean setupNano(long baudRate)
{
  nano.begin(softSerial);

  softSerial.begin(baudRate);
  while (!softSerial.isListening());

  while (softSerial.available()) softSerial.read();

  nano.getVersion();

  if (nano.msg[0] == ERROR_WRONG_OPCODE_RESPONSE)
  {
    nano.stopReading();
    Serial.println(F("Module continuously reading. Asking it to stop..."));
    delay(1500);
  }
  else
  {
    softSerial.begin(115200);
    nano.setBaud(baudRate);
    softSerial.begin(baudRate);
    delay(250);
  }

  nano.getVersion();
  if (nano.msg[0] != ALL_GOOD) return false;

  nano.setTagProtocol();
  nano.setAntennaPort();

  return true;
}

try flip-flopping the code blocks and see if it will read UID at all? A half second delay between reads seems really long to me (especially if the device is set to read once), perhaps try adjusting that too?

nano.startreading() is starting an embedded reading command in the M6E. Now the M6E is working autonomously and reads constantly with sending regular updates. The issue is that when the driver is sending a request for the TID it will check that the response is on the request sent, but instead receives the update from the embedded reading. With the instruction stopreading() it will stop reading and sending constantly. you should send that first then read the TID and startreading again.

I have developed an extended version of the sparkfun library (https://github.com/paulvha/ThingMagic/t … ib_special). It has additional features and look at example15 that might help you.