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
#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 CORRECTBUT OTHERS ARE WRONG :0
In:?TÓÓð680070D0D
Can someone guide me through this? I'd truly appreciate your help.