Whenever you open the Serial Monitor in the Arduino IDE to inspect sensor data or flash new firmware to a board, you are utilizing the UART (Universal Asynchronous Receiver-Transmitter) protocol. Unlike I2C and SPI, UART is asynchronous, meaning it requires no shared clock signal to synchronize data exchange, relying only on two wires.
UART Pins and Cross-Connection
UART communication establishes a point-to-point link between two devices using cross-coupled transmit and receive lines.
| Pin | Function | Proper Wiring Configuration |
|---|---|---|
| TX | Transmit | Connects directly to the RX pin of the target device. |
| RX | Receive | Connects directly to the TX pin of the target device. |
| GND | Common Ground | Mandatory shared reference ground for voltage levels. |
Critical UART Transmission Parameters
Because UART lacks a shared clock line, both communicating devices must be configured with identical transmission parameters beforehand.
- Baud Rate: Transmission speed measured in bits per second (standard rates include 9600 or 115200 baud). Both sides must match.
- Start & Stop Bits: Frame markers that signal the beginning and completion of each data byte.
- Parity Bit: Optional bit for error detection (the vast majority of projects use the 8N1 format: 8 data bits, no parity, 1 stop bit).
Arduino UART Code Example
Arduino provides the built-in Serial object to interact with the onboard hardware UART transceiver.
void setup() {
// Initialize UART communication at 115200 baud
Serial.begin(115200);
Serial.println("UART interface ready!");
}
void loop() {
// Check if incoming bytes are available in the serial buffer
if (Serial.available() > 0) {
char incomingChar = Serial.read();
// Echo the received character back to the console
Serial.print("Received: ");
Serial.println(incomingChar);
}
}
Expanding Ports with SoftwareSerial
On boards with a single hardware UART port like the Arduino Uno (pins 0 and 1, used by USB debugging), you can emulate extra serial ports on arbitrary GPIO pins using the SoftwareSerial library to communicate with GPS, Bluetooth (HC-05), or GSM modules.