RDM6300 Worked and now doesn't [RESOLVED]

Hey there guys,

I have been messing around with Arduino for a little bit and have a project with five RDM6300 readers. Wanted to have five of them each read a chip and "unlock" if in the right order. I got them working last week where most of them would give my Arduino UNO a data signal. Now, this week I ordered a Mega board and tried it again and nothing is happening. I switched back to the old board and nothing happened. I was following some code I found online that I had working for the UNO board that was meant for the MEGA board. I just don't understand what is going on.

--Details--

So in my code I check for Serial.available(). If it is it pushes the data through the TX port, or in my case pin three on the UNO. I have the RDM6300 hooked up correctly to the UNO, like seen on online photos and videos. I have 125khz chips, like needed for the RDM6300 board. I have looked through a lot of the normal question and answer forums for this problem and am coming up empty. If I remove the "> 0" it just outputs -1, -1, -1, -1, -1...

Anyone able to shine some light on this problem I am having? I was going to connect four of these boards into the MEGA and call it good, but I just can't get them to work anymore.

Thank you in advanced~

This is what I am working on for my main code for my project

#include <SoftwareSerial.h>

#define NREADER  2
#define NSAVER  5
#define NTAGS 5
#define TAGLEN  14
 
//Lights and such for the code
int data1 = 0;
int ok = -1;
//int yes = 13;
//int no = 12;
//int win = 0;
//int tControl = 0;
//int t1 = 8;
//int t2 = 9;
//int t3 = 10;
//int t4 = 11;

int chip[NTAGS] = {
0,
0,
0,
0,
0,
};

 
//// use first sketch in http://wp.me/p3LK05-3Gk to get your tag numbers
////int tag1[14] = {2,52,48,48,48,56,54,66,49,52,70,51,56,3};
//int tag1[14] = {2,51,56,48,48,56,65,52,53,51,57,67,69,3};
//int tag2[14] = {2,52,48,48,48,56,54,67,54,54,66,54,66,3};
//int tag3[14] = {2,52,48,48,48,56,54,67,54,54,66,54,66,3};
//int tag4[14] = {2,52,48,48,48,56,54,67,54,54,66,54,66,3};
//int tag5[14] = {2,52,48,48,48,56,54,67,54,54,66,54,66,3};
int newtag[14] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // used for read comparisons

int tags[NTAGS][TAGLEN] = {
  {2,48,53,48,48,48,52,68,65,48,48,68,66,3}, //Bottle 1
  {2,48,53,48,48,48,54,51,51,55,55,52,55,3}, //Bottle 2
  {2,48,53,48,48,48,52,67,48,67,54,48,55,3}, //Bottle 3
  {2,48,53,48,48,48,54,51,51,53,66,54,66,3}, //Bottle 4
  {2,48,53,48,48,48,52,65,54,68,53,55,50,3}, //Bottle 5 / backup
};


SoftwareSerial readers[NREADER] = {
  SoftwareSerial(2, 3),
  SoftwareSerial(4, 5),
};

void setup()
{
  //readers.begin(9600);
  Serial.begin(9600);  // start serial to PC 
}
 
boolean comparetag(int aa[14], int bb[14])
{
  boolean ff = false;
  int fg = 0;
  for (int cc = 0 ; cc < 14 ; cc++)
  {
    if (aa[cc] == bb[cc])
    {
      fg++;
    }
  }
  if (fg == 14)
  {
    ff = true;
  }
  return ff;
}

//void readTags()
//{
//  ok = -1;
//  
//  if (RFID.available() > 0) 
//  {
//    // read tag numbers
//    delay(100); // needed to allow time for the data to come in from the serial buffer.
// 
//    for (int z = 0 ; z < 14 ; z++) // read the rest of the tag
//    {
//      data1 = RFID.read();
//      newtag[z] = data1;
//    }
//    RFID.flush(); // stops multiple reads
// 
//    // do the tags match up?
//    //checkmytags(); CUT OUT RIGHT NOW.
//  }
// 
//  // now do something based on tag type
//  if (ok > 0) // if we had a match
//  {
//    Serial.println("Accept");
//        for (int z = 0 ; z < 14 ; z++) // read the rest of the tag
//    {
//      Serial.print(newtag[z]);
//      Serial.print(", ");      
//    }
//    digitalWrite(yes, HIGH);
//    delay(1000);
//    digitalWrite(yes, LOW);
//    ok = -1;
//  }
//  else if (ok == 0) // if we didn't have a match
//  {
//    Serial.println("Rejected");
//        for (int z = 0 ; z < 14 ; z++) // read the rest of the tag
//    {
//      Serial.print(newtag[z]);
//      Serial.print(", ");      
//    }
//    ok = -1;
//    Serial.println();
//    Serial.println();
//    digitalWrite(no, HIGH);
//    delay(1000);
//    digitalWrite(no, LOW);
//  }
//}

///////////////////////////////////////////////////////////////////////////////////

void readTagsNew(int reader_index)
{
  Serial.begin(9600);
  ok = -1;
  Serial.println("Start");
  SoftwareSerial RFID = readers[reader_index];
  RFID.begin(9600); // Start serial to RFID reader
  delay(200); // needed to allow time for the data to come in from the serial buffer. 
  Serial.println(RFID);
  //if (RFID.available() > 0)
  if (RFID > 0)
  {
    Serial.println("RFID Read");
    delay(100); 
    for (int z = 0 ; z < 14 ; z++) // read the rest of the tag
    {
      data1 = RFID.read();
      newtag[z] = data1;
    }
    RFID.flush(); // stops multiple reads
    if (memcmp(newtag, tags[reader_index], sizeof(tags[reader_index])) == 0)
    {
      
      chip[reader_index] = 1;
      
    }
    else
    {
      Serial.println("No compare");
    }
    Serial.println("Chip");
    Serial.println(chip[reader_index]);
    for (int z = 0 ; z < 14 ; z++) // read the rest of the tag
    {
      Serial.print(newtag[z]);
      Serial.print(",");    
    }
    Serial.println(""); 
    RFID.end();
  }
}

void loop()
{
//  for (int r = 0; r < NREADER; r++)
//  {
//  readTagsNew(r);
//  }


  Serial.println("Read 0");
  delay(1000);
  readTagsNew(0);
  //delay(2000);

//  Serial.println("Read 1");
//  delay(1000);
//  readTagsNew(1);
//  delay(2000);


  if (chip[0] == 1)
  {
    Serial.println("Accept chip1");
    if (chip[1] == 1)
    {
      Serial.println("Accept chip2");
      if (chip[2] == 1)
      {
        Serial.println("Accept chip3");
        if (chip[3] == 1)
        {
          Serial.println("Accept chip4");
          if (chip[5] == 1)
          {
            Serial.println("Accept chip5");
            
            Serial.println("Accepted all");
          }
        }
      }
    }
  }  
}

What I have running on the board currently to test if anything is working.

#include <SoftwareSerial.h>
SoftwareSerial RFID(2, 3); // RX and TX
//SoftwareSerial RFID(0, 1); // RX and TX
 
int data1 = 0;
int ok = -1;
int yes = 13;
int no = 12;
 
// use first sketch in http://wp.me/p3LK05-3Gk to get your tag numbers
int tag1[14] = {2,52,48,48,48,56,54,66,49,52,70,51,56,3};
int tag2[14] = {2,52,48,48,48,56,54,67,54,54,66,54,66,3};
int tag3[14] = {2,51,56,48,48,56,65,52,53,51,57,67,69,3};
int newtag[14] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // used for read comparisons
 
void setup()
{
  RFID.begin(9600);    // start serial to RFID reader
  Serial.begin(9600);  // start serial to PC 
  pinMode(yes, OUTPUT); // for status LEDs
  pinMode(no, OUTPUT);
}
 
boolean comparetag(int aa[14], int bb[14])
{
  boolean ff = false;
  int fg = 0;
  for (int cc = 0 ; cc < 14 ; cc++)
  {
    if (aa[cc] == bb[cc])
    {
      fg++;
    }
  }
  if (fg == 14)
  {
    ff = true;
  }
  return ff;
}
 
void checkmytags() // compares each tag against the tag just read
{
  ok = 0; // this variable helps decision-making,
  // if it is 1 we have a match, zero is a read but no match,
  // -1 is no read attempt made
  if (comparetag(newtag, tag1) == true)
  {
    ok++;
  }
  if (comparetag(newtag, tag2) == true)
  {
    ok++;
  }
    if (comparetag(newtag, tag3) == true)
  {
    ok++;
  }
}
 
void readTags()
{
  ok = -1;
 
  if (RFID.available() > 0) 
  {
    // read tag numbers
    delay(100); // needed to allow time for the data to come in from the serial buffer.
 
    for (int z = 0 ; z < 14 ; z++) // read the rest of the tag
    {
      data1 = RFID.read();
      newtag[z] = data1;
    }
    RFID.flush(); // stops multiple reads
 
    // do the tags match up?
    checkmytags();
  }
 
  // now do something based on tag type
  if (ok > 0) // if we had a match
  {
    Serial.println("Accepted");
    digitalWrite(yes, HIGH);
    delay(1000);
    digitalWrite(yes, LOW);
 
    ok = -1;
  }
  else if (ok == 0) // if we didn't have a match
  {
    Serial.println("Rejected");
    for (int z = 0 ; z < 14 ; z++) // read the rest of the tag
    {
      Serial.print(newtag[z]);
      Serial.print(", ");      
    }
    Serial.println();
    Serial.println();
    digitalWrite(no, HIGH);
    delay(1000);
    digitalWrite(no, LOW);
 
    ok = -1;
  }
}
 
void loop()
{
  readTags();
}

Hi,

first thing I noticed you start the built in Serial two times. Once in the steup and once in the readTagsNew. AFAIK it ist not that a problem, but imho not nice ^^

Second what you could try is change the

SoftwareSerial readers[NREADER] = {
  SoftwareSerial(2, 3),
  SoftwareSerial(4, 5),
};

to

int readerPins[NREADER][2] = {
  {2,3},
  {4,5}
}

...

SoftwareSerial RFID(readers[reader_index][0], readers[reader_index][1]);

The problem might be, that if you store the SoftwareSerial object in an array, you might get something back which is not really that what you need. But it is just a wild guess, and with this it might work. Otherwise you could check if the Rx Tx wiring is correct. Unfortunately I can't hook up my things right now to test it. :confused:

Cheers,

stiefel:
Hi,

first thing I noticed you start the built in Serial two times. Once in the steup and once in the readTagsNew. AFAIK it ist not that a problem, but imho not nice ^^

Second what you could try is change the

SoftwareSerial readers[NREADER] = {

SoftwareSerial(2, 3),
  SoftwareSerial(4, 5),
};




to


int readerPins[NREADER][2] = {
  {2,3},
  {4,5}
}

...

SoftwareSerial RFID(readers[reader_index][0], readers[reader_index][1]);




The problem might be, that if you store the SoftwareSerial object in an array, you might get something back which is not really that what you need. But it is just a wild guess, and with this it might work. Otherwise you could check if the Rx Tx wiring is correct. Unfortunately I can't hook up my things right now to test it. :/

Cheers,

Hey there, would I put the new SoftwareSerial in the setup()?

This is where I got the main body of the code from for that: arduino-multi-RDM6300-rfid-readers/nano328/sketch.ino at master · kaworu/arduino-multi-RDM6300-rfid-readers · GitHub

WORKS!

So, I did a few hours of research with a lot of stuff coming up empty. However, with posts on here I thought about looking into the SerialSoftware as a problem. I found that if I used the official "Serial" name instead of renaming it that it worked. I picked up my MEGA board to do everything on it. I found that if I kept the Serial, Serial1, Serial2, and Serial3 the same I was able to read them. Weird part was that I was reading them through the TX port before, but in the after process I was reading them through the RX port.

Please note that if you have some LED bulbs around that plugging them into the RDM6300 will help, the three pin side will tell you if it is reading a RFID chip or not. Anything after that is with your arduino.

I used the code below and it worked. I will also link an article that worked for figuring out the solution! :slight_smile:

Thank you everyone!

Source link: RDM6300 | tronixstuff.com

#include <SoftwareSerial.h>
#define NTAGS 10
#define TAGLEN  14
 
//Lights and such for the code
int data1 = 0;
int ok = -1;
//int yes = 13;
//int no = 12;
int win = 2;

int chip[NTAGS] = {
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
};

int newtag[14] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // used for read comparisons

int tags[NTAGS][TAGLEN] = {
  {2,48,53,48,48,48,52,68,65,48,48,68,66,3}, //Bottle 1
  {2,48,53,48,48,48,54,51,51,55,55,52,55,3}, //Bottle 2
  {2,48,53,48,48,48,52,67,48,67,54,48,55,3}, //Bottle 3
  {2,48,53,48,48,48,54,51,51,53,66,54,66,3}, //Bottle 4
  {2,48,53,48,48,48,52,65,54,68,53,55,50,3}, //Bottle 5 / backup
  /////////////////////////////OLD READS//////////////////////////
  {68,65,48,48,68,66,3,2,48,53,48,48,48,52}, //1 OLD Bottle
  {51,51,55,55,52,55,3,2,48,53,48,48,48,54}, //2 OLD Bottle
  {67,48,67,54,48,55,3,2,48,53,48,48,48,52}, //3 OLD Bottle
  {51,51,53,66,54,66,3,2,48,53,48,48,48,54}, //4 OLD Bottle
};

void setup()
{
  //pinMode(yes, OUTPUT); // for status LEDs
  //pinMode(no, OUTPUT);
  pinMode(win, OUTPUT);
  Serial.begin(9600);  // start serial to PC 
  Serial1.begin(9600);
  Serial2.begin(9600);
  Serial3.begin(9600);
}

//void readThis(int number)
//{
//  SoftwareSerial Serial5;
//  if (number == 0)
//  {
//    Serial5 = Serial;
//  }
//  if (number == 1)
//  {
//    Serial5 = Serial1;
//  }
//  if (number == 2)
//  {
//    Serial5 = Serial2;
//  }
//  if (number == 3)
//  {
//    //SoftwareSerial Serial5 = Serial3;
//  }
//  else
//  {
//    Serial.println("Invalid");
//  }
// Serial5.begin(9600);
// Serial.print("Serial: ");
// Serial.println(number);
// if (Serial5.available() > 0) {
// // read the incoming number on serial RX
//     for (int z = 0 ; z < 14 ; z++) // read the rest of the tag
//    {
//      data1 = Serial5.read();
//      newtag[z] = data1;
//      Serial.print(newtag[z]);
//      Serial.print(",");  
//    }
//        Serial5.flush(); // stops multiple reads
//    if (memcmp(newtag, tags[0], sizeof(tags[0])) == 0)
//    {
//      chip[0] = 1;
//    }
//    else
//    {
//      Serial.println("No compare");
//    }
//    Serial.print("Chip: ");
//    Serial.println(chip[0]);
// }  
//}


void loop()
{
//readThis(Serial1);
  if (chip[0] == 1)
  {
    Serial.println("Accept chip1");
    if (chip[1] == 1)
    {
      Serial.println("Accept chip2");
      if (chip[2] == 1)
      {
        Serial.println("Accept chip3");
        if (chip[3] == 1)
        {
          Serial.println("Accept chip4");
          Serial.println("Accept All");
          digitalWrite(win, HIGH);
        }
        else
        {
          digitalWrite(win, LOW);
        }
      }
      else
      {
        digitalWrite(win, LOW);
      }
    }
    else
    {
      digitalWrite(win, LOW);
    }
  }
  else
  {
    digitalWrite(win, LOW);
  }

/////////////////////////////////////////////////////////
  
 Serial.println("Serial 0"); 
 if (Serial.available() > 0) {
 // read the incoming number on serial RX
     for (int z = 0 ; z < 14 ; z++) // read the rest of the tag
    {
      data1 = Serial.read();
      newtag[z] = data1;
      Serial.print(newtag[z]);
      Serial.print(",");  
    }
        Serial.flush(); // stops multiple reads
    if (memcmp(newtag, tags[0], sizeof(tags[0])) == 0)
    {
      chip[0] = 1;
    }
    else
    {
      //chip[0] = 0;
    }
    Serial.print("Chip: ");
    Serial.println(chip[0]);
 }  

//////////////////////////////////////////////////////////////
 
 Serial.println(" ");
 Serial.println("Serial 1"); 
  if (Serial1.available() > 0) {
 // read the incoming number on serial RX
     for (int z = 0 ; z < 14 ; z++) // read the rest of the tag
    {
      data1 = Serial1.read();
      newtag[z] = data1;
      Serial.print(newtag[z]);
      Serial.print(",");  
    }
        Serial.flush(); // stops multiple reads
    if (memcmp(newtag, tags[1], sizeof(tags[1])) == 0)
    {
      chip[1] = 1;
    }
    else
    {
      //chip[1] = 0;
    }
    Serial.print("Chip: ");
    Serial.println(chip[1]);    
 }  

//////////////////////////////////////////////////////////////////
 
 Serial.println(" ");
 Serial.println("Serial 2"); 
   if (Serial2.available() > 0) {
 // read the incoming number on serial RX
     for (int z = 0 ; z < 14 ; z++) // read the rest of the tag
    {
      data1 = Serial2.read();
      newtag[z] = data1;
      Serial.print(newtag[z]);
      Serial.print(",");  
    }
    Serial.flush(); // stops multiple reads
    if (memcmp(newtag, tags[2], sizeof(tags[2])) == 0)
    {
      chip[2] = 1;
    }
    else
    {
      //chip[2] = 0;
    }
    Serial.print("Chip: ");
    Serial.println(chip[2]);   
 }  

/////////////////////////////////////////////////////////////////
 
 Serial.println(" ");
 Serial.println("Serial 3"); 
   if (Serial3.available() > 0) {
 // read the incoming number on serial RX
     for (int z = 0 ; z < 14 ; z++) // read the rest of the tag
    {
      data1 = Serial3.read();
      newtag[z] = data1;
      Serial.print(newtag[z]);
      Serial.print(",");  
    }
    Serial.flush(); // stops multiple reads
    if (memcmp(newtag, tags[3], sizeof(tags[3])) == 0)
    {
      chip[3] = 1;
    }
    else
    {
      //chip[3] = 0;
    }
    Serial.print("Chip: ");
    Serial.println(chip[3]); 
 }  

/////////////////////////////////////////////////////////////////////////
 
 Serial.println(" ");
 delay(2000);
}