Has Anyone got the m6e nano rfid reader working with an arduino due?

Has Anyone got the m6e nano RFID reader working with an Arduino due or other board that doesn’t support software serial?

I have changed the example code where it says softserial and changed it to Serial2 and connected RX Tx from the reader to the corresponding serial2 pins on the Arduino.

But when I run the program, it just says “Module failed to respond. Please check wiring.” indicating that it has failed the setup code. possibly due to a wiring issue but there are just 4 wires and I made sure it’s correct.

if I use a 5/3.3v voltage divide or not it makes no difference either

I don’t get it.

Please help Thanks

Modified “Example1_Constant_Read” code

/*
  Reading multiple RFID tags, simultaneously!
  By: Nathan Seidle @ SparkFun Electronics
  Date: October 3rd, 2016
  https://github.com/sparkfun/Simultaneous_RFID_Tag_Reader

  Constantly reads and outputs any tags heard

  If using the Simultaneous RFID Tag Reader (SRTR) shield, make sure the serial slide
  switch is in the 'SW-UART' position
*/

//#include <SoftwareSerial.h> //Used for transmitting to the device

//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(9600);
  while (!Serial); //Wait for the serial port to come online

  if (setupNano(38400) == false) //Configure nano to run at 38400bps
  {
    Serial.println(F("Module failed to respond. Please check wiring."));
    while (1); //Freeze!
  }

  nano.setRegion(REGION_NORTHAMERICA); //Set to North America

  nano.setReadPower(500); //5.00 dBm. Higher values may caues USB port to brown out
  //Max Read TX Power is 27.00 dBm and may cause temperature-limit throttling

  Serial.println(F("Press a key to begin scanning for tags."));
  while (!Serial.available()); //Wait for user to send a character
  Serial.read(); //Throw away the user's character

  nano.startReading(); //Begin scanning for tags
}

void loop()
{
  if (nano.check() == true) //Check to see if any new data has come in from module
  {
    byte responseType = nano.parseResponse(); //Break response into tag ID, RSSI, frequency, and timestamp

    if (responseType == RESPONSE_IS_KEEPALIVE)
    {
      Serial.println(F("Scanning"));
    }
    else if (responseType == RESPONSE_IS_TAGFOUND)
    {
      //If we have a full record we can pull out the fun bits
      int rssi = nano.getTagRSSI(); //Get the RSSI for this tag read

      long freq = nano.getTagFreq(); //Get the frequency this tag was detected at

      long timeStamp = nano.getTagTimestamp(); //Get the time this was read, (ms) since last keep-alive message

      byte tagEPCBytes = nano.getTagEPCBytes(); //Get the number of bytes of EPC from response

      Serial.print(F(" rssi["));
      Serial.print(rssi);
      Serial.print(F("]"));

      Serial.print(F(" freq["));
      Serial.print(freq);
      Serial.print(F("]"));

      Serial.print(F(" time["));
      Serial.print(timeStamp);
      Serial.print(F("]"));

      //Print EPC bytes, this is a subsection of bytes from the response/msg array
      Serial.print(F(" epc["));
      for (byte x = 0 ; x < tagEPCBytes ; x++)
      {
        if (nano.msg[31 + x] < 0x10) Serial.print(F("0")); //Pretty print
        Serial.print(nano.msg[31 + x], HEX);
        Serial.print(F(" "));
      }
      Serial.print(F("]"));

      Serial.println();
    }
    else if (responseType == ERROR_CORRUPT_RESPONSE)
    {
      Serial.println("Bad CRC");
    }
    else
    {
      //Unknown response
      Serial.print("Unknown error");
    }
  }
}

//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(Serial2); //Tell the library to communicate over software serial port

  //Test to see if we are already connected to a module
  //This would be the case if the Arduino has been reprogrammed and the module has stayed powered
  Serial2.begin(baudRate); //For this test, assume module is already at our desired baud rate
  while (!Serial); //Wait for port to open

  //About 200ms from power on the module will send its firmware version at 115200. We need to ignore this.
  while (Serial2.available()) Serial2.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
    Serial2.begin(115200); //Start software serial at 115200

    nano.setBaud(baudRate); //Tell the module to go to the chosen baud rate. Ignore the response msg

    Serial2.begin(baudRate); //Start the software serial port, this time at user's chosen baud rate

    delay(250);
  }

  //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
}

Have it connected to standard serial often and works perfect.

The Due is 3v3 and you need to power the RFID with 5V. You should make a voltage divider is between the RFID TX and Due RX. No need on the Due TX line to RX Nano. I had to use resistors to do so, as putting a level converter in between did not work. The Nano already has a level converter on the board and it did not work with another converter in between.

Else some questions :

Where did you connect the wires, on the serial connector ?

How did you set the onboard switch ?

To which pins did you connect on the Due?

Minor error in setupNano(), but I don’t expect that to be the root cause:

while (!Serial); //Wait for port to open

should read

while (!Serial2); //Wait for port to open

I have the VCC of the reader connected to the 5v pin on the due, that is putting out 5v right? or should I power it separately with the power input next to the serial pins on the reader?

I guess il try that

I connected the RX and tx from due to the RFID reader to the 6 pins where it says serial( I’m assuming that’s what you mean by serial connector), worked perfectly on uno using soft serial

from what am understanding the switch doesn’t matter in this setup but, it is set to the HW serial just in case

pins are connected to the tx2 and rx2 through a custom shield (shield definitely works)

just double-checked my the schematic for my custom shield turns out it was connected to tx3 and rx3, so I changed the code to serial3, but still nothing

On the smaller side of the Nano, there are connections. It states ‘serial’ for a number of them (NC, TX, RX VCC, NC, GND) and next to it are GPIO1, GND, LV2, LV2, LV3, Lv4. You should use the serial connector TX and RX. These are independent of the switch setting. To which pins on the Due you connect ?

yup connecting where it says ‘serial’ on the RFID reader.

Tx from the RFID reader is connected through a voltage divider ( using a 1k ohm resistor for the first resistor and a 2k for the second ) to rx3 due

Rx from RFID reader is connected straight Tx3 on due

as stated above I di change the code to serial3 instead of serial2 including the: while (!Serial3); //Wait for port to open

and I’m also now powering the rfid reader with a power supply through the power in pins right next to the serial pins.

still the same result.

I just checked to make sure the RFID reader is working using my Uno (software serial) and it works perfectly, and I cheked the due using a blink sketch and it also works.

I don’t get it, is there anything you did differently when you used the RFID reader?

(I start to think I should just scrap the idea of connecting it to the due and use an Arduino Uno or micro and connect the micro to due via i2c)

I have tested again on an ESP32 (which is 3V3) and it works without problems.

Do you see the power led on the Nano ?

can you share pictures of the connection?

Try run the code below (it works for me now set to Serial3). It will also show debug information that might help to understand what is happening

/*
  Reading multiple RFID tags, simultaneously!
  By: Nathan Seidle @ SparkFun Electronics
  Date: October 3rd, 2016
  https://github.com/sparkfun/Simultaneous_RFID_Tag_Reader

  Constantly reads and outputs any tags heard

  If using the Simultaneous RFID Tag Reader (SRTR) shield, make sure the serial slide
  switch is in the 'SW-UART' position
*/

#include "SparkFun_UHF_RFID_Reader.h" //Library for controlling the M6E Nano module

// if you plan to use softserial:  initalize that here, else comment it out the 2 lines
//#include <SoftwareSerial.h> //Used for transmitting to the device
//SoftwareSerial softSerial(2, 3); //RX, TX

// define the serial port to use (E.g. softSerial, Serial1 etc)
#define NanoSerial Serial3

RFID nano; //Create instance

void setup()
{
  Serial.begin(115200);
  while (!Serial); //Wait for the serial port to come online

  // added for debug Nano
  nano.enableDebugging();
  
  if (setupNano(38400) == false) //Configure nano to run at 38400bps
  {
    Serial.println(F("Module failed to respond. Please check wiring."));
    while (1); //Freeze!
  }

  nano.setRegion(REGION_NORTHAMERICA); //Set to North America

  nano.setReadPower(500); //5.00 dBm. Higher values may caues USB port to brown out
  //Max Read TX Power is 27.00 dBm and may cause temperature-limit throttling

  Serial.println(F("Press a key to begin scanning for tags."));
  while (!Serial.available()); //Wait for user to send a character
  Serial.read(); //Throw away the user's character

  nano.startReading(); //Begin scanning for tags
}

void loop()
{

  if (nano.check() == true) //Check to see if any new data has come in from module
  {
    byte responseType = nano.parseResponse(); //Break response into tag ID, RSSI, frequency, and timestamp

    if (responseType == RESPONSE_IS_KEEPALIVE)
    {
      Serial.println(F("Scanning"));
    }
    else if (responseType == RESPONSE_IS_TAGFOUND)
    {
      //If we have a full record we can pull out the fun bits
      int rssi = nano.getTagRSSI(); //Get the RSSI for this tag read

      long freq = nano.getTagFreq(); //Get the frequency this tag was detected at

      long timeStamp = nano.getTagTimestamp(); //Get the time this was read, (ms) since last keep-alive message

      byte tagEPCBytes = nano.getTagEPCBytes(); //Get the number of bytes of EPC from response

      Serial.print(F(" rssi["));
      Serial.print(rssi);
      Serial.print(F("]"));

      Serial.print(F(" freq["));
      Serial.print(freq);
      Serial.print(F("]"));

      Serial.print(F(" time["));
      Serial.print(timeStamp);
      Serial.print(F("]"));

      //Print EPC bytes, this is a subsection of bytes from the response/msg array
      Serial.print(F(" epc["));
      for (byte x = 0 ; x < tagEPCBytes ; x++)
      {
        if (nano.msg[31 + x] < 0x10) Serial.print(F("0")); //Pretty print
        Serial.print(nano.msg[31 + x], HEX);
        Serial.print(F(" "));
      }
      Serial.print(F("]"));

      Serial.println();
    }
    else if (responseType == ERROR_CORRUPT_RESPONSE)
    {
      Serial.println("Bad CRC");
    }
    else
    {
      //Unknown response
      Serial.print("Unknown error");
    }
  }
}


//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(NanoSerial); //Tell the library to communicate over serial port

  //Test to see if we are already connected to a module
  //This would be the case if the Arduino has been reprogrammed and the module has stayed powered
  NanoSerial.begin(baudRate); //For this test, assume module is already at our desired baud rate
  while(!NanoSerial); //Wait for port to open

  //About 200ms from power on the module will send its firmware version at 115200. We need to ignore this.
  while(NanoSerial.available()) NanoSerial.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
    NanoSerial.begin(115200); //Start software serial at 115200

    nano.setBaud(baudRate); //Tell the module to go to the chosen baud rate. Ignore the response msg

    NanoSerial.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
}

Thank you so much for your help btw

so I uploaded the code and this is what I got in the serial monitor

sendCommand: [FF] [00] [03] [1D] [0C]

response: [7B] [14] [02] [00] [00] [14] [12] [08] [00] [30] [00] [00] [02] [20] [19] [06] [10] [01] [01] [01] [11] [00] [00] [00] [10]

Corrupt response

sendCommand: [FF] [04] [06] [00] [00] [96] [00] [E0] [41]

sendCommand: [FF] [00] [03] [1D] [0C]

response: [EF] [FF] [00] [03]

Corrupt response

Module failed to respond. Please check wiring.

and some times it just times out instead of giving a response at all

power led on the reader is definitely on

https://photos.app.goo.gl/WSpfiwHKaAs8ovZU8

Arduino due is under the custom shield (green PCB)

The right request is being sent, but in the response does not look to be correct . The first request is asking for the version, as that fails it sent to set for 38400 and request again the version, with only part of the answer to be received and scrambled.

What kind of board do you have on top off the due ?

You seem to power the Nano from an external 5V power supply. Where is the GND connection from that power supply to the GND Due board/ Nano ? (can not detect on the pictures)

Can you try another GND connection?

regards,

Paul

In those pictures I’m powering it from arduino. (had the power supply there to to test with it previously) at some point later I will remove the due from the setup and make a Simple straight forward setup with just the reader, due and voltage set up and post pictures.

Green PCB is custom shield that I designed for the project.

re did the circuit as simple as possible

https://photos.app.goo.gl/knQXAniwRbBRo9W18

still the same response

sendCommand: [FF] [00] [03] [1D] [0C]

Time out 1: No response from module

sendCommand: [FF] [04] [06] [00] [00] [96] [00] [E0] [41]

sendCommand: [FF] [00] [03] [1D] [0C]

response: [BF] [10] [03] [00] [00] [14] [12] [08] [00] [20] [00] [00] [02] [20] [19] [02] [10] [00] [01] [01] [11]

Corrupt response

The module failed to respond. Please check the wiring.

I got it to work easily with an Arduino micro

HI, this is weird. The Nano does not respond to the first request for device info (which happens normally when the Nano is in a different baud-rate), Then the baud-rate is changed and the request repeated and a response is sent BUT the data received is corrupted. So it did recognize to work on different baud-rate and did recognize the request and did sent a response. BUT that is received corrupted ??

Can you try to set to lower speed than 38400? ( e.g. 19200).

Does it work on another serial port ?

Does SoftSerial work (even for a test ?)?

Remove the resistors for the voltage divider and connect directly. Normally this does not cause issues for a short test.

dosent it just automaticaly just send the requsest to change baud rate if it dosent get a response from the reader?

unfortunatly the due dose not suport softserial for what ever reason, at least not the standard softserial libery, mabey ther is a difrent on that works idk.

by difrent serial port do yo mean adifrent com port/ usb port or rx tx on the due, i tried the later that just gives the same responce, and i have used difrent computers to upload the scetches/ view serial monitor.

i think it is software related mabey the due is just not compatable with it, wich is a bummer.

And changing baud rate doesn’t help

and removing the voltage divider makes it worse since I don’t get any response back from the reader and it just times out

now I’m even having trouble running it on the micro and uno I modified that code you gave me to work on soft serial and that’s the only code where the reader connects properly. having trouble running the example sketch now on the uno. I wonder if the reader is going bad, I hope not.

it is getting weirder each moment. Maybe it did run hot and you have to wait for cool down. Otherwise if you have a USB/serial converter and PC running windows, you can download the universial reader assistent (URA) and try to connect on windows.

so this code works on my uno

/*
  Reading multiple RFID tags, simultaneously!
  By: Nathan Seidle @ SparkFun Electronics
  Date: October 3rd, 2016
  https://github.com/sparkfun/Simultaneous_RFID_Tag_Reader

  Constantly reads and outputs any tags heard

  If using the Simultaneous RFID Tag Reader (SRTR) shield, make sure the serial slide
  switch is in the 'SW-UART' position
*/

#include <SoftwareSerial.h> //Used for transmitting to the device

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(9600);
  while (!Serial); //Wait for the serial port to come online

  if (setupNano(38400) == false) //Configure nano to run at 38400bps
  {
    Serial.println(F("Module failed to respond. Please check wiring."));
    while (1); //Freeze!
  }

  nano.setRegion(REGION_NORTHAMERICA); //Set to North America

  nano.setReadPower(500); //5.00 dBm. Higher values may caues USB port to brown out
  //Max Read TX Power is 27.00 dBm and may cause temperature-limit throttling

  Serial.println(F("Press a key to begin scanning for tags."));
  while (!Serial.available()); //Wait for user to send a character
  Serial.read(); //Throw away the user's character

  nano.startReading(); //Begin scanning for tags
}

void loop()
{
  if (nano.check() == true) //Check to see if any new data has come in from module
  {
    byte responseType = nano.parseResponse(); //Break response into tag ID, RSSI, frequency, and timestamp

    if (responseType == RESPONSE_IS_KEEPALIVE)
    {
      Serial.println(F("Scanning"));
    }
    else if (responseType == RESPONSE_IS_TAGFOUND)
    {
      //If we have a full record we can pull out the fun bits
      int rssi = nano.getTagRSSI(); //Get the RSSI for this tag read

      long freq = nano.getTagFreq(); //Get the frequency this tag was detected at

      long timeStamp = nano.getTagTimestamp(); //Get the time this was read, (ms) since last keep-alive message

      byte tagEPCBytes = nano.getTagEPCBytes(); //Get the number of bytes of EPC from response

      Serial.print(F(" rssi["));
      Serial.print(rssi);
      Serial.print(F("]"));

      Serial.print(F(" freq["));
      Serial.print(freq);
      Serial.print(F("]"));

      Serial.print(F(" time["));
      Serial.print(timeStamp);
      Serial.print(F("]"));

      //Print EPC bytes, this is a subsection of bytes from the response/msg array
      Serial.print(F(" epc["));
      for (byte x = 0 ; x < tagEPCBytes ; x++)
      {
        if (nano.msg[31 + x] < 0x10) Serial.print(F("0")); //Pretty print
        Serial.print(nano.msg[31 + x], HEX);
        Serial.print(F(" "));
      }
      Serial.print(F("]"));

      Serial.println();
    }
    else if (responseType == ERROR_CORRUPT_RESPONSE)
    {
      Serial.println("Bad CRC");
    }
    else
    {
      //Unknown response
      Serial.print("Unknown error");
    }
  }
}

//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

  //Test to see if we are already connected to a module
  //This would be the case if the Arduino has been reprogrammed and the module has stayed powered
  softSerial.begin(baudRate); //For this test, assume module is already at our desired baud rate
  while (!softSerial); //Wait for port to open

  //About 200ms from power on the module will send its firmware version at 115200. We need to ignore this.
  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

    delay(250);
  }

  //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
}

but this does not, I just get the check wiring error

I don’t get it they look identical to me in terms of RFID reader setup

[/*
  Reading multiple RFID tags, simultaneously!
  By: Nathan Seidle @ SparkFun Electronics
  Date: October 3rd, 2016
  https://github.com/sparkfun/Simultaneous_RFID_Tag_Reader

  Constantly reads and outputs any tags heard

  If using the Simultaneous RFID Tag Reader (SRTR) shield, make sure the serial slide
  switch is in the 'SW-UART' position
*/

#include <SoftwareSerial.h> //Used for transmitting to the device

SoftwareSerial softSerial(2,3); //RX, TX

//#define NanoSerial softSerial


#include "SparkFun_UHF_RFID_Reader.h" //Library for controlling the M6E Nano module
RFID nano; //Create instance

byte tagEPCBytes;
bool CheckforTags = true;
bool CurentlyReadingTags = false;

int CorrectID[] {226,0,0,25,23,25,1,119,16,16,150,180};
int CorrectUD[64]{72,73};




void setup()
{
  pinMode(13,OUTPUT);
  
  
  Serial.begin(9600);
  while (!Serial); //Wait for the serial port to come online

  if (setupNano(38400) == false) //Configure nano to run at 38400bps
  {
    Serial.println(F("Module failed to respond. Please check wiring."));
    while (1); //Freeze!
  }

  nano.setRegion(REGION_NORTHAMERICA); //Set to North America

  nano.setReadPower(500); //5.00 dBm. Higher values may caues USB port to brown out
  //Max Read TX Power is 27.00 dBm and may cause temperature-limit throttling

/*  Serial.println(F("Press a key to begin scanning for tags."));
  while (!Serial.available()); //Wait for user to send a character
  Serial.read(); //Throw away the user's character*/
  
}

void loop()
{
  //----------------------------------------------------------------------------------------- EPC code start  ------------------------------------
  if ( CheckforTags == true) 
  { 
    
    if (CurentlyReadingTags == false)
    {
      nano.startReading(); //Begin scanning for tags
      delay(10);
      CurentlyReadingTags = true;
    }  
    delay(10);
    

   if (nano.check() == true) //Check to see if any new data has come in from module
   {
    byte responseType = nano.parseResponse(); //Break response into tag ID, RSSI, frequency, and timestamp

    if (responseType == RESPONSE_IS_KEEPALIVE)
    {
      Serial.println(F("Scanning"));
    }
    else if (responseType == RESPONSE_IS_TAGFOUND)
    {
      //If we have a full record we can pull out the fun bits
      int rssi = nano.getTagRSSI(); //Get the RSSI for this tag read

      long freq = nano.getTagFreq(); //Get the frequency this tag was detected at

      long timeStamp = nano.getTagTimestamp(); //Get the time this was read, (ms) since last keep-alive message

      byte tagEPCBytes = nano.getTagEPCBytes(); //Get the number of bytes of EPC from response

      Serial.print(F(" rssi["));
      Serial.print(rssi);
      Serial.print(F("]"));

      Serial.print(F(" freq["));
      Serial.print(freq);
      Serial.print(F("]"));

      Serial.print(F(" time["));
      Serial.print(timeStamp);
      Serial.print(F("]"));

      //Print EPC bytes, this is a subsection of bytes from the response/msg array
      Serial.print(F(" epc["));
      for (byte x = 0 ; x < tagEPCBytes ; x++)
      {
        if (nano.msg[31 + x] < 0x10) Serial.print(F("0")); //Pretty print
        Serial.print(nano.msg[31 + x]);
        Serial.print(F(" "));
      }
      Serial.print(F("]"));

      Serial.println();
    }
    else if (responseType == ERROR_CORRUPT_RESPONSE)
    {
      Serial.println("Bad CRC");
    }
    else
    {
      //Unknown response
      Serial.print("Unknown error");
    }
  } //nano.check end
  
} //bool check tags end

for (byte x = 0 ; x < 12 ; x++)
  {
    Serial.print(nano.msg[31 + x],HEX);
    Serial.print("      ");
    Serial.println(CorrectID[x],HEX);
    
 
 if (nano.msg[31 + x] != CorrectID[x])
   {
    break;
   }
 
   
   if(x == 11)
   { 
   nano.stopReading();
   CurentlyReadingTags = false;
    
   CheckforTags = false;
    
   Serial.println("ID is Correct");
   Serial.println(" ");
   }
  } 
   delay(10);
  
 //-------------------------------------------------------- EPC code end ----------------------------------------------------------------
  
 
 if ( CheckforTags == false) {
 


  //Read the data from the tag
  byte responseType;
  byte myData[64];
  byte myDataLength = sizeof(myData); //Tell readUserData to read up to 64 bytes
  
  responseType = nano.readUserData(myData, myDataLength); //readUserData will modify myDataLength to the actual # of bytes read

  if (responseType == RESPONSE_SUCCESS)
  {
    //Print User Data
    Serial.print(F("Size ["));
    Serial.print(myDataLength);
    Serial.print(F("] User data["));
    for (byte x = 0 ; x < myDataLength ; x++)
    {
      if (myData[x] < 0x10) Serial.print(F("0"));
      Serial.print(myData[x], HEX);
      Serial.print(F(" "));
      
      if (myData[x] != CorrectUD[x]) break;
      
      if(x == 63) 
      {
      Serial.println("UD is Correct");
      Serial.println(" ");
      
      digitalWrite(13,HIGH);
      delay(5000);
      digitalWrite(13,LOW);
      
      }
    }
    Serial.println(F("]"));
  
  delay(1000);
  CheckforTags = true;  
  }
  
  
  else
    Serial.println(F("Error reading tag data"));
 
 }
 
 
  

  

}











//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(); //Tell the library to communicate over software serial port

  //Test to see if we are already connected to a module
  //This would be the case if the Arduino has been reprogrammed and the module has stayed powered
  softSerial.begin(baudRate); //For this test, assume module is already at our desired baud rate
  while (!softSerial); //Wait for port to open

  //About 200ms from power on the module will send its firmware version at 115200. We need to ignore this.
  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

    
     delay(250);
  }

  //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
}

/code]

I think in setupNano(), the line nano.begin(); should read nano.begin(softSerial);

If user doesn’t specify the port to use then Serial will be used by default.