Go Down

Topic: Is there a reason why the Arduino TX/RX pins marked so strangely? (Read 96 times) previous topic - next topic

MikeX

Why does the pin labeled "RX" mean "connect your device's RX pin here"?

Not "this is the pin that receives (RX) data from your device"?  :o

This is illogical and not intuitive.


DrAzzy

Uh, 0 / RX is not where you should connect RX, it's where you connect TX.

Notice how they have the pins flipped there, ie, it's pin 1/TX, then 0/RX.

MikeX

Uh, 0 / RX is not where you should connect RX, it's where you connect TX.
That's what I was thinking too, as it's just logical.

But as a matter of fact, when sending data from the PC through the USB-to-Serial chip, it is the RX (D0) pin where the data being sent by the PC is coming out.

I've had to bring out an oscope to find the problem. Swapped the pins and everything started working. ::)

dmjlambert

Here is the reason they are weird:

RX can be used as a regular everyday data pin if you are not using Serial at all in your sketch.  It is digital pin 0. 

TX can be used as a regular everyday data pin if you are not using Serial at all in your sketch.  It is digital pin 0.

So that is why on the Nano they are marked with RX0 and TX1. 
When you connect a serial device to the Nano, connect the device's TX pin to the Nano RX pin, and connect the device's RX pin to the Nano TX pin.   Also connect a common ground.  Be careful when connecting the Nano's TX pin to RX of a device if that device has 3.3V logic levels.  You may need to use a logic level converter or voltage divider resistors. 

Regarding signals from your computer, the FTDI or CH340G chip on your Nano converts the computer's USB to serial.  If you have a look at the Nano schematic, you will see the TX pin of the USB serial converter chip is connected to the RX pin of the ATmega328.   And the RX pin of the USB serial converter chip is connected to the TX pin of the ATmega328. 

You haven't seen real weird yet.  Are you ready?  Have a look at the Pro Micro and Pro Mini.  The RX pin is marked RXI (that is the letter I).  It means input, so you can remember it is input (as if receive was not good enough of an indicator of data direction).   This pin also serves as digital pin 0 if you're not using Serial.  Digital pin 0 is not limited to just input, you can actually use it for input or output just like any other digital pin.   The TX pin is marked TXO (as in the letter O).  It means output as if transmit is not adequate to remember that.  The TX pin serves as digital pin 1, just like on the Nano.  Just like pin 0, you can use pin 1 as input or output.

RXI = digital pin 0 if you are not using Serial in your sketches (or not using Serial1 on the Pro Micro)
TXO = digital pin 1 if you are not using Serial in your sketches (or not using Serial1 on the Pro Micro)

With the small print and font used on the board surface, it is pretty hard to see the difference between I and 1.  A slashed 0 helps.    But, some manufacturers use RX1 (number 1) and TX0 (number 0) on these pins. 



jboyton

It's a matter of perspective. You're viewing it from the perspective of your PC. Look it at the other way. RX is the receiving pin for the Nano. It's the receive pin for the Atmega328. Atmel calls that pin "RXD".

MikeX

It's a matter of perspective.
Good thing there are only 2 perspectives here, so it's easy to figure out the idiosyncrasy.  :smiley-lol:


So the TX pin on the Arduino receives data from the ATmega328, and is connected to RX on the USB-to-Serial chip.

And the RX pin on the Arduino sends data to the ATmega328, and is connected to TX on the USB-to-Serial chip.

dmjlambert

Yes, jboyton said it very well, that it is a matter of perspective.   The pins are labeled from the perspective of the ATmega328.  The way I see it is:

The TX pin on the ATmega328, which is available on the header, transmits data to RX on the USB-to-Serial chip.  It can also transmit to any other device connected to the TX header pin, such as transmitting to the RX pin of a Bluetooth module.

The RX pin on the ATmega328, which is available on the header, receives data from TX on the USB-to-Serial chip.  It can also receive from any other device connected to the RX header pin, such as receiving from the TX pin of a Bluetooth module.

jboyton

So the TX pin on the Arduino receives data from the ATmega328, and is connected to RX on the USB-to-Serial chip.
That's not the way I'd say it. But yes, I suppose so. In one sense each link in the chain is both receiver and transmitter.

For example, if you send me an email we would say you were the sender and I was the receiver. But what about your keyboard? Or my screen? They both receive and send the message. So it is with the Arduino pin.

To be fair, the TX/RX pins confuse me all the time. I like the fact that one of my boards actually has little arrows next to the RX and TX labels.

Go Up