Two RFID (RDM6300) Readers on One Arduino Uno

I am trying to control a door lock with two RFID readers (RDM6300); I am using two RFID readers (one for coming in and one for going out). While working with one RFID reader is not a problem for me, I cannot make two work correctly. The code below works sometimes, but unfortunately not all the time :frowning:

#include <SoftwareSerial.h>

SoftwareSerial rIn(2,3);
SoftwareSerial rOut(10,11);
String tagString;
char tagIn[14];
char tagOut[14];

void setup() {
  Serial.begin(9600);
  rOut.begin(9600);
  rIn.begin(9600);
  Serial.println("System Activated!");
}

void loop() {
  if(rIn.available()) {
    int readingIn = rIn.readBytesUntil(3, tagIn, 15); //EOT (3) is the last character in tag
    Serial.print("In:");
    Serial.println(tagIn);
    rIn.flush();
    memset(tagIn, 0, sizeof(tagIn));
    rOut.listen();
  } else {
    memset(tagIn, 0, sizeof(tagIn));
    rOut.listen();
  }
  
  if(rOut.available()) {
    int readingOut = rOut.readBytesUntil(3, tagOut, 15); //EOT (3) is the last character in tag
    Serial.print("Out:");
    Serial.println(tagOut);
    rOut.flush();
    memset(tagOut, 0, sizeof(tagOut));
    rIn.listen();
  } else {
    memset(tagOut, 0, sizeof(tagOut));
    rIn.listen();
  }
}

The Serial Monitor displays my tag number correctly once or twice, but displays some weird characters most of the times as follows. BTW in this attempt, I moved my tag from one reader to the other at moderate speed.

System Activated!
In:?TÓÓð
Out:ºþ680070D0DF1ºþ680070D0DF17680070D0DF17680070D0DF17680070D0DF17
In:680070D0DF17 << THIS ONE IS CORRECT :wink: BUT OTHERS ARE WRONG :0
In:?TÓÓð680070D0D

Can someone guide me through this? I’d truly appreciate your help.

Only one instance of SoftwareSerial can listen at a time. Do you want that to be the inside instance or the outside instance?

You need a Mega, with 4 hardware serial ports.

Thanks PaulS for your prompt reply.

PaulS:
Only one instance of SoftwareSerial can listen at a time. Do you want that to be the inside instance or the outside instance?

You need a Mega, with 4 hardware serial ports.

It’s okay for me to have only one RFID reader reading at a time, like what promised on http://arduino.cc/en/Tutorial/TwoPortReceive. But can an Arduino Uno not read the RFID readers one after another?

BTW, PaulS, what are “inside instance” and “outside instance”? :blush:

BTW, PaulS, what are “inside instance” and “outside instance”?

SoftwareSerial rIn(2,3);
SoftwareSerial rOut(10,11);

Presumably, rIn refers to the inside reader and rOut refers to the outside reader. Both are instances of the SoftwareSerial class.

It’s okay for me to have only one RFID reader reading at a time, like what promised on http://arduino.cc/en/Tutorial/TwoPortReceive. But can an Arduino Uno not read the RFID readers one after another?

If a tag is passed by the reader that is not the active instance, it is ignored. So, no, the Arduino can not read from two readers “one after another” in the way that you mean.

If you make the insider reader active until a tag is read, and then make the outside reader active (rOut.listen();), you can then read from the outside reader. When the outside reader reads a tag, you could make the insider reader active again (rIn.listen();).