I'm a beginner to Arduino programming. Before attempting anything more complex I'm trying to get some very basic functionality first, so using some of the sketchbook examples I'm trying to get the most basic serial loopback working. I used the SerialEvent sketch as a reference point to come up with this:

String inputString = "";
bool stringComplete = false;
int inByte = 0;

void setup() {
  // initialize serial:
  // wait for serial port to connect. Needed for native USB port only
  while (!Serial) {
  // reserve 200 bytes for the inputString:
  Serial.println("Hello world\n");

void loop() {
  while (Serial.available()) {
    char inChar = (char)Serial.read();
    inputString += inChar;
    if (inChar == '\n') {
      stringComplete = true;
  if (stringComplete) {
    inputString = "";
    stringComplete = false;

When I flash that image to the Arduino and then open the Serial monitor, everything appears to work fine. As pictured below, whatever I type gets echoed back to me after pressing Enter:

successful loopback

However, it's a different story when I connect the TX and RX pins on the board, as pictured here:


As soon as I do that, the serial communication becomes totally non-responsive. It still prints out "Hello world" at the beginning, but it no longer echoes back the messages that get sent in, as you can see here:

non-responsive loopback

I should say that even when it is no longer echoing messages back, the yellow "RX" light on the board does still briefly light up when I press Enter. But the "TX" light doesn't. Note that both lights light up if I unplug the jumper wire.

It seems to me that what I'm trying to do here is a very simple thing, that really shouldn't be this hard. Is there something obvious I'm missing? Any advice?

  • put the ATmega328p in reset for loopback test or at least upload a sketch without Serial.begin. RX/TX of the 328p is attached to RX/TX of the USB chip and to the RX, TX pins on header. wiring the pins on header together disturbs the communication between the 328p and the USB chip
    – Juraj
    Commented Jan 12, 2020 at 6:49

2 Answers 2


You are trying to use the serial port connected to two devices at a time:

  • to the on-board serial/USB bridge that allows communication with your computer
  • some unspecified external serial device.

Connecting your TX (transmit pin) to two receivers is fine: whatever you write will be received by both.

Connecting your RX to two transmitters doesn't work, you can at most read the data sent by one transmitter.

On the Uno board, there are resistors along the serial connection between the main MCU and the serial/USB bridge. Thanks to the resistor on the RX line, you can connect an external device to the MCU's serial port: The device's TX will override the USB bridge. This means the main MCU can no longer receive what you send it from the serial monitor.


I can not comment, it turns out that this example that you are working is not very suitable, since the RX and TX are directly connected to the USB connection (for Arduino UNO), that is, you can only use these pins as long as it is loaded from Sketch uses An external power supply to connect the Arduino, my recommendation is to work if you have a sensor to verify the transmission of data by serial port. Greetings

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.