Trouble with using multiple RFID readers

Hi there. I've been bashing my head against trying to understand serial transmission on my Arduino Uno for the past couple days. I've got some code here to read from three ID-12LA RFID readers by using software serial and alternating between them using softwareserial.listen(), however the output I get is almost always nothing, or sometimes a single random character.

From my limited understanding, I think that the buffer that is holding the serial data from the ports is getting overwritten when I change the port I am listening to, but I'm unsure how else to effectively listen to three ports at once.

Some general advice on how to go about this would be greatly appreciated, as most the information I've found online is using MFRC522 readers and so doesn't apply as much here.

// Create a software serial objects for the connection to the RFID modules
SoftwareSerial rfid1 = SoftwareSerial( rx1Pin, tx1Pin );
SoftwareSerial rfid2 = SoftwareSerial( rx2Pin, tx2Pin );
SoftwareSerial rfid3 = SoftwareSerial( rx3Pin, tx3Pin );

char val1 = 0; // variable to store the data from software serial port 1
char val2 = 0; // variable to store the data from software serial port 2
char val3 = 0; // variable to store the data from software serial port 3

void setup() {
  Serial.begin(9600); // connect to the serial port
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  rfid1.begin(9600);
  rfid2.begin(9600);
  rfid3.begin(9600);
}

void loop () {
  // read the software serial ports
  rfid1.listen();
  while(rfid1.available() > 0) {
    val1 = rfid1.read();   
    Serial.write(val1);
  }
  rfid2.listen();
  while(rfid2.available() > 0) {
    val2 = rfid2.read();
    Serial.write(val2);
  }
  rfid3.listen();
  while(rfid3.available() > 0) {
    val3 = rfid3.read();
    Serial.write(val3);
  }
}

Some general advice on how to go about this would be greatly appreciated

I am sorry, but the best advice is probably to use an Arduino board with more than one hardware UART, such as a Mega

Using multiple instances of SoftwareSerial is fraught with difficulties, as you have found out.

Okay, that was the conclusion I had come to also, I just thought I should check in case I was missing the obvious.

Thanks for the sanity check :slight_smile: