Target Audience

This article assumes that the reader has a basic understanding of electronic devices, circuits, and terminology.

Introduction

In the world of embedded device communications, there is a small handful of protocols that are used for many different applications. It is often the case that more common protocols that are commonly used for everyday operations, such as FTP and TCP, either do not work with small embedded devices or are unsuitable (often due to power or space requirements). It is in cases like these that more basic, ‘down to the metal’ communications standards such as UART are very useful.
.

What is UART?

UART (Universal Asynchronous Receiver/Transmitter) is a small, efficient communications device, similar to I2C. UART is most often installed in a piece of hardware, embedded in an IC (integrated circuit), that translates communicated data between serial and parallel forms. In other words, a UART device takes a stream of bits of data (most often designed for parallel communication), converts it to bits of serial data for transmission down a single wire, or bus, and then transmits it. At the other end of the wire, another UART device receives the serial bits and converts them back into parallel packages of data. The “Universal” portion of the name refers to the configurability of both the data format and the speeds at which it is transmitted/received.
.
UART is one of the oldest communication devices used by computers, dating its origins back to the 1960s when it was used to connect computers to teletypewriter keyboards, or “teletypes”. In the 1970s it was the protocol used to read and write data to cassette tapes, and later it was used to communicate with modems during the early dial-up days of BBS (Bulletin Board System) services and the Internet. It has since been supplanted with more complex devices that use protocols such as TCP and IP, but its design is still useful with embedded devices.
.

How UARTs Communicate

As mentioned above, UART works by translating between parallel communication and serial communication. Why do this at all, since parallel communication is so much faster? While parallel communication is faster, it’s also much more expensive in terms of both power and the transmission medium. You can send the same batch of data in sequential serial bits, one by one, down a single wire, rather than in synchronized parallel bits, simultaneously, down a bunch of wires. If your application is starved for space, for instance, it may make much more sense to only use one wire. For this reason, UART devices come in very handy in low-power, low-profile situations, such as embedded systems.
.
So how does it work, exactly? The nice thing about asynchronous transmission is that the data can be transmitted without the sender and receiver having to share a clock signal–a signal that can take up valuable data space. Instead, timing is agreed upon in advance between both units, and special bits are added to each data package–each “word”. UARTs use these bits to synchronize to each other. When the transmitter is preparing to send a word, it adds a special START bit to the beginning of the package. This bit alerts the receiver that a data package is coming its way and synchronizes the receiver’s internal clock with the transmitter’s. (Normally, for other transmitter/receiver pairings, all that is necessary to synchronize the two device clocks is that they agree on a transmission speed in bits per second, or “baud”.)
.
After the START bit, the transmitter sends the word. Most UART systems use word lengths of five to ten bits. Bit transmission occurs over a consistent clock time, and the time-synchronized receiver looks at the bus exactly halfway through a designated ‘send’ time to determine if a 1 or a 0 is being sent (if the bus is HIGH, a ‘1’ is being sent; otherwise, it’s a ‘0’). Finally, the transmitter sends a parity bit (if the system has been configured that way) and an END bit. Then it starts another word with another START bit, and the process continues. The receiver, meanwhile, discards the START and STOP bits, uses the parity bit if necessary, records the word, and continues to listen for more data. If the circuit is a duplex (two-way communication) setup, then the same process can repeat in the opposite direction. In some UART systems, wires are not even necessary; infrared (IR) and Bluetooth devices are often set up to transmit and receive via the UART signaling scheme.

Historical bit of trivia: When nothing is being transmitted, the line is held HIGH by both devices, rather than LOW (unpowered.) This convention is a holdover from the days of the telegraph–telegraph lines were held high so each end user could tell that the line was unbroken.

.

Uses for UARTs Persist

UART devices have been around for a long time, and have proven themselves still useful, even alongside devices capable of higher speed communications and gigabit transfer speeds made possible today with fast cloud servers and managed cloud hosting.
.
Most modern microcontrollers contain a UART device; single ICs can contain one, two, or even 8 UARTs on one chip (these last two designs are called DUARTs and OCTARTs, respectively). The Arduino — the popular hobbyist microcontroller IDE — has a UART interface built in on every one of its boards, even the smallest of them. The Raspberry Pi, another popular hobbyist device, can also interface with UART devices. For anyone interested in working with small embedded devices, it’s a worthy device to learn to use.

.