Understanding UART – A Fundamental Communication Protocol in Embedded Systems

The Reliable Backbone of Serial Communication in Industrial Electronics
Introduction
In the world of embedded systems and industrial automation, seamless communication between devices is critical. Whether it’s a microcontroller talking to a sensor, or a human-machine interface (HMI) communicating with a control board, data exchange must be fast, accurate, and reliable.
One protocol that has stood the test of time in these environments is UART — Universal Asynchronous Receiver/Transmitter.
Simple, effective, and widely adopted — UART is a communication staple in PLCs, industrial sensors, IoT devices, and embedded controllers.
In this post, we’ll break down UART in a clear, practical manner:
- What it is and how it works
- Why it matters in embedded systems
- Real-world use cases and configuration
- Best practices for robust UART communication
What is UART?
UART is a hardware communication protocol that enables two devices to exchange data serially — one bit at a time — without the need for a shared clock signal.
Each UART-enabled device has:
- A Transmitter (TX) to send data
- A Receiver (RX) to receive data
These devices convert data between parallel and serial formats, allowing microcontrollers and peripherals to communicate via two simple wires:
TX and RX.
Key Features of UART
| Feature | Description |
|---|---|
| Asynchronous | No clock line required; timing is based on baud rate |
| Full Duplex | Can send and receive data simultaneously |
| Simple Hardware | Only two main wires (TX and RX) |
| Point-to-Point | Designed for direct communication between two devices |
| Configurable | Baud rate, parity, stop bits, and data length can be customized |
How UART Works – The Data Frame
Every UART transmission consists of a data frame, which is structured as follows:
pgsqlCopyEditStart Bit | Data Bits | Parity Bit (optional) | Stop Bit(s)
Breakdown:
- Start Bit (1 bit): Indicates the start of data transmission (logic LOW)
- Data Bits (5-9 bits): Actual data being transferred
- Parity Bit (optional): Error-checking bit (even or odd parity)
- Stop Bits (1-2 bits): Marks the end of the transmission (logic HIGH)
Example: At 9600 baud, 8-N-1 (8 data bits, No parity, 1 stop bit), a byte takes about 1.04 ms to send.
UART vs SPI vs I2C – Protocol Comparison
| Protocol | Wires | Speed | Complexity | Use Case |
|---|---|---|---|---|
| UART | 2 | Low–Med | Simple | Point-to-point comms |
| SPI | 4 | High | Medium | Fast communication w/ sensors, displays |
| I2C | 2 | Medium | Complex | Multi-device communication |
UART is best when you need simple, direct communication between two devices over short to medium distances.
UART in Industrial and Embedded Applications
🔌 Microcontroller to Sensor Communication
E.g., Arduino, STM32, ESP32 talking to GPS modules, RFID readers, etc.
🖥️ HMI to PLC Serial Ports
Older HMI panels often use RS232/RS485 UART interfaces to exchange process data.
📡 Industrial IoT Gateways
UART enables embedded Linux devices to connect to modems, BLE modules, or serial-connected legacy devices.
🔧 Debugging Embedded Code
UART is commonly used for console logging and real-time debugging in firmware development.
Hardware Variants: RS232 and RS485
UART signals are TTL (Transistor-Transistor Logic) by default (0–5V or 0–3.3V), but for longer distances and industrial reliability, they are adapted into:
| Standard | Description | Distance | Multi-Drop? |
|---|---|---|---|
| RS232 | Single-ended, legacy standard | ~15 meters | No |
| RS485 | Differential, noise-resistant | ~1200 meters | Yes |
In industrial settings, RS485 over UART is preferred due to its noise immunity and support for multi-node communication.
How to Configure UART in Embedded Devices
🔧 Parameters to Set:
- Baud Rate: 9600, 19200, 115200, etc.
- Data Bits: Typically 8
- Stop Bits: 1 or 2
- Parity: None, Even, or Odd
- Flow Control: Optional (XON/XOFF or RTS/CTS)
🛠 Tools for Testing:
- Serial Monitors (e.g., Tera Term, PuTTY, RealTerm)
- USB to UART converters
- Oscilloscopes or logic analyzers
Sample UART Code (Arduino)
cppCopyEditvoid setup() {
Serial.begin(9600); // Set baud rate
}
void loop() {
Serial.println("Reading sensor...");
delay(1000);
}
This basic snippet sends a message over UART every second, which can be monitored via a serial terminal.
UART Best Practices
✔️ Match baud rates exactly on both devices
✔️ Always check TX ↔ RX wiring (cross-connect)
✔️ Implement software or hardware flow control if data overflow is a concern
✔️ Use ground reference wire for stability
✔️ Shield UART lines in high-EMI environments
✔️ Prefer RS485 for longer distances or industrial environments
Troubleshooting UART Issues
| Symptom | Possible Cause |
|---|---|
| Garbled Data | Baud rate mismatch |
| No Communication | TX/RX reversed, missing GND |
| Intermittent Loss | EMI, weak power supply |
| Garbage Characters | Incorrect parity or stop bits |
Future Trends: UART Still Relevant?
Yes! Even with the rise of USB, CAN, and Ethernet, UART remains relevant because:
- It’s lightweight and easy to implement in firmware
- Perfect for low-power, embedded systems
- Integrated in nearly every microcontroller
- Ideal for bootloaders and low-level diagnostics
Conclusion
UART is the unsung hero of embedded communications. While it may not offer the highest speed or complexity, its simplicity, reliability, and wide adoption make it a cornerstone of embedded and automation projects.
Whether you’re configuring a PLC, programming a microcontroller, or integrating an industrial gateway, understanding UART will give you a firm grasp of embedded communication fundamentals.