Sub topic 4
Voltage Levels and Wiring: TX, RX and Ground
Assume you know the Arduino setup() and loop() functions, bytes, binary numbers, HIGH and LOW, and basic C++ syntax. This chapter focuses on the electrical side of UART. A UART connection can have correct software settings and still fail if the voltage standard or wiring is wrong.
The three basic connections
A simple UART link usually uses three wires:
- TX, or transmit, sends bytes from one device.
- RX, or receive, accepts bytes on the other device.
- GND, or ground, provides the voltage reference used to interpret the signals.
Connect the transmitter of one device to the receiver of the other:
| Device A | Device B |
|---|---|
| TX | RX |
| RX | TX |
| GND | GND |
TX and RX are named from each device's point of view. Device A's TX is an output, so it must reach Device B's RX input. Connecting TX to TX gives two outputs driving each other, while RX to RX connects two inputs that receive nothing.
The shared ground matters because a digital input measures the signal voltage relative to its own ground. Without a common reference, a wire carrying 3.3 volts may not look like a valid logic high to the receiving device. A missing ground can cause unreliable data or prevent communication entirely.
Logic-level UART
Many microcontrollers use logic-level UART, sometimes called TTL UART or CMOS UART. These signals are single-ended, which means each signal is measured against ground. The signal is usually idle at a logic high level and goes low for the start bit.
The voltage depends on the hardware:
- A 5 V Arduino Uno generally outputs signals near 0 V and 5 V.
- A 3.3 V board generally outputs signals near 0 V and 3.3 V.
- A 5 V input may not safely accept a 5 V signal from another voltage-sensitive device.
- A 3.3 V input may be damaged by a 5 V signal even if it recognizes 3.3 V as HIGH.
Do not assume that two connectors labeled UART are electrically compatible. Check the board documentation for its signal voltage and input limits. A voltage divider, level-shifting module, or compatible USB-to-serial adapter may be needed.
A simple resistor divider can reduce a 5 V TX signal before it reaches a 3.3 V RX input. For example, a 1 kΩ resistor between the 5 V TX output and the 3.3 V RX input, followed by a 2 kΩ resistor from the RX input to ground, produces about 3.3 V. This arrangement is normally suitable for a one-way signal, but confirm the receiving pin's requirements. For bidirectional communication, use a proper level shifter or separate dividers for the appropriate direction.
Do not confuse UART with RS-232
UART describes a method for sending framed bits. It does not define one universal voltage standard. RS-232 is a separate electrical standard that commonly uses voltage levels above and below ground and inverted logic. A typical RS-232 interface may use positive and negative voltages, while an Arduino pin expects a small, ground-referenced logic signal.
Therefore, an Arduino UART pin must not connect directly to a traditional RS-232 port. Use an RS-232 transceiver such as a MAX232-type interface. The transceiver converts between Arduino logic-level UART and RS-232 electrical signals.
RS-485 is different again. It uses a differential pair, often labeled A and B, rather than one TX wire and one RX wire referenced directly to ground. Differential signaling rejects noise over longer cables. Many RS-485 systems support several devices on one bus, but they require suitable transceivers, bus termination, and correct direction control.
| Interface | Signal style | Typical use |
|---|---|---|
| Logic-level UART | Single-ended TX, RX, and GND | Microcontroller to module |
| RS-232 | Inverted, higher positive and negative voltages | Older computers and equipment |
| RS-485 | Differential A/B pair | Long cables and shared buses |
Practical wiring checks
Before powering the circuit, verify these points:
- Both devices use the same electrical standard.
- The signal voltage from each TX pin is safe for the other RX pin.
- TX from each device connects to RX on the other.
- The devices share a ground when using single-ended logic-level UART.
- The cable is short enough for the signal speed and environment.
- Both devices use the same baud rate and frame format.
If text appears as random symbols, first check the baud rate and frame format. If there is no response, inspect TX/RX crossing and ground. If the circuit behaves intermittently, check voltage compatibility, loose connections, cable length, and electrical noise. A logic analyzer can show whether the waveform has the expected idle-high state, start bits, and bit timing.
Exercise
An Arduino Uno is connected to a 3.3 V sensor. The sensor's TX connects to the Arduino's RX, and the Arduino's TX connects directly to the sensor's RX. The ground is shared. What remaining risk must you check?
Show answer
Check whether the Arduino's 5 V TX output is safe for the sensor's 3.3 V RX input. If it is not 5 V tolerant, add a level shifter or suitable voltage divider on the Arduino-to-sensor direction.