# Arduino UNO Rx/Tx speaks to itself

I'm trying to make my chinese arduino (which use a chinese CH340G chip) speaks to itself via serial. I have wired rx/tx together.

Then, I run the arduino IDE and go to the serial monitor.

When I write a message, the arduino should respond with the exact same message, right ? Actually, when I write a message, the arduino doesn't respond anything...

• Please see for instance arduinobasics.blogspot.se/2012/07/… Commented Feb 4, 2016 at 16:09
• please re-read my question, I don't want to use any software, I have put a physical jumper between rx and tx pin Commented Feb 4, 2016 at 16:17
• You cannot use the same serial port to have the Arduino speak to the computer and speak to itself. Commented Feb 4, 2016 at 16:20
• well in fact I have read that the arduino uno only have 1 serial port and that this port is shared between the computer and the serial pin on the arduino... Isn't that right ? Commented Feb 4, 2016 at 16:22
• This will depend on the bootloader and which state it leaves the port at. Commented Feb 4, 2016 at 16:41

## 4 Answers

As Mikael Patel pointed out in his answer, you have set up a voltage divider. Mikael has thoughtfully provided a schematic of the clone Uno, where the relevant part is here:

## Equivalent circuit

If you jumper together pins D0 and D1 (Rx and Tx) on the Uno effectively you have made this circuit:

## Testing

If I set up this with a function generator, I get this result:

You can see that for a square-wave input of 0 to 5V, we only get an output of 2.16 to 5V.

## What is LOW?

Now looking at the datasheet for the DC characteristics we see:

For an input to register as LOW it has to be no higher than `0.3 * Vcc = 0.3 * 5`. Thus the voltage cannot be higher than 1.5V. Since we are measuring 2.16V, that will not count as a LOW.

Now admittedly that is for the Atmega328P and not the CH340G, but it will probably have similar characteristics.

I found a datasheet for the CH340G, and that shows even stricter requirements for a LOW signal:

## Official Uno

Comparing to the official Uno circuit:

You will note there that the indicator LEDs are on a different circuit, and thus do not form a voltage divider.

## The Maths

The clone Uno circuit above can be re-arranged like this:

Given that the LEDs have a voltage drop of 1.86V (measured in practice, and about right for the red LEDs I am using) then effectively we have the resistors R1 and R2 connected to 3.14V.

Since they are in parallel they are effectively 500 ohms.

Now using the formula for voltage dividers:

``````1000 / (1000 + 500) * (5 - 1.86) = 2.09V
``````

This is close enough to the observed result. I didn't check each resistor to make sure it was exactly in spec.

I don't think R4 affects the results because it is effectively "floating".

• Great job, Nick! You filled in the blanks and added yet a level of engineering (again). Thanks! Hope others appreciates your knowledge sharing. Commented Feb 4, 2016 at 22:41
• Thanks, @MikaelPatel. There is one thing I'm not happy with, I can't make the maths work out. I am measuring a voltage drop of 1.86V over the LEDs with the 1k resistor. Commented Feb 4, 2016 at 23:12
• If I remove the D2 LED then I measure 1.567V which agrees with: `1000 / 2000 * (5 - 1.86) = 1.57` Commented Feb 4, 2016 at 23:16
• I think I worked the maths out, see amended answer. Commented Feb 4, 2016 at 23:45

After some research I found the below schematics of an Arduino UNO with CH340G. A loop-back is not possible as there is a voltage divider (1K ohm, i.e. RX/TX LED) resistors on the RX and TX line.

Tested on a Chinese Arduino Uno clone (VISduino) with CH340G and just as you wrote a loop-back does not work. Tested also an Arduino Mega 2560 clone with CH340G and a Duemilanove clone with FTDI. Both these work just fine.

Cheers!

• Thanks for your research :) so it means that a message which come through the RX pin can't go to the usb because of this resistor, right ? Commented Feb 4, 2016 at 18:58
• Nja, if you look at the circuit and add the loop-back connecting pin 0 and pin 1. The TXD signal from the CH340G has to go though 1 K and then back through another 1 K to the RXD on the CH340G. The TTL signal is not low enough after that (my guess). Commented Feb 4, 2016 at 19:03
• My loopback test does work. Commented Feb 4, 2016 at 19:27
• @EdgarBonet Your loopback test on an Arduino Uno clone with CH340G does work? Commented Feb 4, 2016 at 19:37
• No, it's a real Uno, but the RX and TX are wired almost the same as in your clone, with the same 1K resistors. Commented Feb 4, 2016 at 19:39

There is no problem doing a loopback on an Arduino Uno, but you cannot use the serial monitor at the same time. I wrote the following test program, which works as expected:

``````const int LED_PIN = 13;

void setup() {
pinMode(LED_PIN, OUTPUT);
Serial.begin(9600);
}

void loop() {
uint8_t data = random();
Serial.write(data);
while (!Serial.available()) { /* wait */ }
if (Serial.read() == data) {

// Two short pulses = success
digitalWrite(LED_PIN, HIGH);
delay(100);
digitalWrite(LED_PIN, LOW);
delay(100);
digitalWrite(LED_PIN, HIGH);
delay(100);
digitalWrite(LED_PIN, LOW);
delay(700);
} else {

// One long pulse = failure
digitalWrite(LED_PIN, HIGH);
delay(500);
digitalWrite(LED_PIN, LOW);
delay(500);
}
}
``````

There are, however, two caveats with this naive program:

1. the loopback wire has to be removed before uploading
2. after connecting the wire, the Arduino has to be reset to get out of the while loop.
• This is loop-back on the Arduino side. I think the OP was referring to loop-back on the USB side. It is a good answer but maybe not the right question. Commented Feb 4, 2016 at 19:41
• yes Mikael Patel is right. Commented Feb 4, 2016 at 19:55
• @MikaelPatel: Oh, now I see your point. Since the OP said he wanted to “make my chinese arduino speaks to itself”, it seemed to me he wanted to loop back the Arduino side. I also assumed he did not understand that having two TX talking on the same line cannot work. Commented Feb 4, 2016 at 19:58

the capacitor on pin 4 is connected to GND not to +5V

• Not on the schematic provided by Mikael Patel. In any case, this doesn't answer the original question. Commented Sep 22, 2016 at 21:38