Arduino Mega Multiple Serial Loopback

Hello Forum,

I was debugging a strange issue with one of my projects, I reduced my code down to the code below. Essentially I am writing data to Serial2 and I am getting the data back in when I do Serial2.read(). Note though, this is with an Arduino Mega with NO connections at all, just the board plugged in with USB to computer. I also attached a picture of my code and serial monitor.

void setup() {
  Serial.begin(9600);
  Serial2.begin(9600);
  Serial.println("ready");
}

void loop() 
{
  if(Serial2.available()){
    Serial.write(Serial2.read());
  } 
  Serial2.println("I shouldn't see this");
  delay(100);
}

Can't open your picture on my cell phone; not your fault.

If you have rx2 and tx2 connected together, what you should see in serial monitor is the text "I shouldn't see this".

Hello everyone,

I think I solved my problem, it looks like some EM/interference stuff. If I plug jumper wires into the TX and RX lines and not hook them up to anything else it increases the affect, if I touch the wires that increases it too, but if I touch ground with my other hand it goes away, same thing if I attach a jumper to ground, it stops. Looks like if there is no load the RX line will pick up interference from the nearby TX wire?

It looks like when I had this in my project the RX line was disconnected and the TX line was connected. It was definitely confusing me since I was getting TX but no RX, and the RX I was getting was what I was sending!