Not receiving serial data when 2 RFID readers are connected

I am using a mega 2560. essentially, I have 2 RFID readers hooked up to 2 different serial ports. Attached is the fritzing circuit diagram. I am testing 8 different readers in pairs. the first 2 readers I used work perfectly, all data comes in as expected. I remove a prototyping reader, and place a new one in, and nothing works. either reader by itself works perfectly; it is only when both are placed does the problem arise.
any help is appreciated, the code I am using is below.

int RFIDResetPin = 13;


void setup()
{
  Serial.begin(9600);
  Serial1.begin(9600);
  Serial2.begin(9600);
  pinMode(RFIDResetPin, OUTPUT);
  digitalWrite(RFIDResetPin, HIGH);
}

void loop() {

  char tagString1[13];
  int index = 0;
  boolean reading1 = false;
  boolean reading2 = false;
  ///////////////////////////////////////
  //this reads from the reader installed
  //on serial1, which is pin 19
  //////////////////////////////////////
  while (Serial1.available() > 0) {

    int readByte1 = Serial1.read(); //read next available byte

    if (readByte1 == 2) reading1 = true;
    if (readByte1 == 3) reading1 = false;

    if (reading1 && readByte1 != 2 && readByte1 != 10 && readByte1 != 13) {
      tagString1[index] = readByte1;
      index++;
    }
  }
  Serial.println(String("Reader 1: ") + tagString1); //the tag itself

delay(1);
  clearTag(tagString1); //Clear the char of all value
  resetReader(); //reset the RFID reader
  //////////////////////////////////////////////////
  // This bit reads from serial2, located on pin 17
  /////////////////////////////////////////////////
  while (Serial2.available() > 0) {

    int readByte2 = Serial2.read();

    if (readByte2 == 2) reading2 = true;
    if (readByte2 == 3) reading2 = false;

    if (reading2 && readByte2 != 2 && readByte2 != 10 && readByte2 != 13) {
      tagString1[index] = readByte2;
      index++;
    }
  }
  Serial.println(String("Reader 2: ") + tagString1);

  clearTag(tagString1);
  resetReader();
}




void resetReader() {
  ///////////////////////////////////
  //Reset the RFID reader to read again.
  ///////////////////////////////////
  digitalWrite(RFIDResetPin, LOW);
  digitalWrite(RFIDResetPin, HIGH);
  delay(150);
}

void clearTag(char one[]) {
  ///////////////////////////////////
  //clear the char array by filling with null – ASCII 0
  //Will think same tag has been read otherwise
  ///////////////////////////////////
  for (int i = 0; i < strlen(one); i++) {
    one[i] = 0;
  }
}

RFID_Project_Breadboard.PNG

Karma points for actually using the F**ing schematic view! Although it seems to be very low resolution and I can not read the pin names. Could you post it again in higher resolution?

Your code is rather primitive and doesn't really function to read two devices simultaneously. You seem to do a reset in the middle, which might get correct data from the second reader but the first one has been sending for some time, while you are concentrating on the other one, so it may have filled the Serial1 buffer and started discarding data.

Look into using Robin2's system for reading both devices. You can process every character that arrives within a few microseconds, so you can just scan both of them really really fast until one of them produces a "complete" message.

My code isn't the best, but for some reason a lot of the seemingly more simple methods haven't shown any sign of working properly in my implementation. I have edited my question with a higher resolution.

the weirdest thing is that it works fine with 2 of my sensors, but not at all with the rest. the initial string "Reader N: " comes through, but none of the tag data. if i hook up one of the readers to the 3.3v pin, and the other to the 5v pin, it works, but only if one of the aforementioned sensors is together with a new one. super weird. I pretty sure it is a voltage problem, as that reset you mentioned was a recent edition to see if I can fix this problem. tell me any ideas you have, all help is appreciated. the readers I am using are called ID-20la readers, the data sheet can be found here: https://cdn.sparkfun.com/datasheets/Sensors/ID/ID-2LA,%20ID-12LA,%20ID-20LA2013-4-10.pdf

OP's image...

Is there a library? Get the library example working with just one reader at a time.

I'm not sure exactly what you mean by a library, could you elaborate?

Edit: I initially used softwareserial, but that did not work. I also uploaded a slightly better schematic that more clear. I made my own routes instead of letting the automatic one do it

You have absolutely no supply decoupling on the power supplies to each reader.

Readers generate interference on the power lines and unless they are decoupled adequately then they can prevent each other from working.

They also need separating by about two feet if they are not going to suffer a reduction in range as well.

In my final iteration they will be aprox 5 feet from each other. can you please explain the power decoupling a bit more in depth?

also, range will increase when they are farther apart? at what point will you lose that advantage?

  1. Decoupling refers to the fact that digital circuits generate extremely high currents when switching between high and low or low and high. Like several amps. Enough to power your bike at 30mph, but only for a nanosecond or less.

While that is a tiny amount of power (a billionth of 30mph) it is still current that must come from somewhere. That “somewhere” is the decoupling capacitor.

  1. Two receivers close together will interact. It is always better to separate them. But the difference between 5ft and 6ft will be too tiny to measure.

range will increase when they are farther apart?

No range will decrease when they are closer together, there is a big difference.

In my final iteration they will be aprox 5 feet from each other

When I worked designing RFID readers we recommended that readers had to be a minimum of 1 meter apart. It was amazing how many installations were made with a reader each side of the door, so just inches apart. We recommended when having a reader each side of a door that they be on different sides.

Mind you we were using properly designed readers and not just cheap and cheerful Chinese single chip on a PCB stuff, so the range was much larger.

As to decoupling MorganS is correct, here is my page on it. Treat an RFID reader as if it were a motor.
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

thank you all. your article was very informative. Practically however, I don't know exactly how to implement a capacitor into my circuit. do you have any tips for that?

What are the actual modules you have? They probably already have decoupling onboard.

Avram_Alter:
thank you all. your article was very informative. Practically however, I don't know exactly how to implement a capacitor into my circuit. do you have any tips for that?

Sorry but I don’t understand what you mean, can you be more specific.

On that page I linked to, the capacitor inductor and capacitor, go between the power supply and the readers power input.

I attempted to use 100uF capacitors on each loop, but they did not solve the problem. I added the new schematic to the first post, as well as here. maybe I am placing them wrong.

MorganS:
What are the actual modules you have? They probably already have decoupling onboard.

arduino mega 2560s paired with Innovation ID-20LA readers. Data sheet can be found here: https://cdn.sparkfun.com/datasheets/Sensors/ID/ID-2LA,%20ID-12LA,%20ID-20LA2013-4-10.pdf

Avram_Alter:
I attempted to use 100uF capacitors on each loop, but they did not solve the problem. I added the new schematic to the first post, as well as here. maybe I am placing them wrong.

You have no inductors, and only two capacitors and they are too big to filter these high frequencies. You need a 0.1uF ceramic, for best results put the 100uF in parallel with them.
Did you read that link? Did you understand it?

I read through it, but i had a bit of a difficult time understanding it. i dont know a lot about circuitry other than very basic information. I have 2 0.1 uF capacitors (it has a little 104 on the side), but I dont know which side is positive or negative, or if that even matters.

but I dont know which side is positive or negative, or if that even matters.

It doesn't matter, because ceramic capacitors are not polarised.

I keep saying I would use an inductor like this on the power input to EACH reader:-

There might be other things wrong with your set up as well, I haven't looked at your code yet because you need to get the hardware right first.

the thing is, i got one set up working without any capacitors or inductors. I know my code works, even if it is very crudely written.

I think I am pretty dumb. I have been strapping an extra pin to ground this entire time, and have been running my capacitors between the wrong pins. I have added the new, normal schematic in the next comment, maybe that can clear things up. still is not working, however.

As you can see I don’t have any running in parallel yet. I only have 2 capacitors available to use, the 0,1 uF and the 100 uF. I have some linear regulators and resistors, but not much else.

this is the current an updated schematic