UART – The Universal Asynchronous Receiver-Transmitter
UART is a full duplex serial interface. It enables two devices to communicate over just three wires and supports variable speeds.
Like the name suggests, UART is an asynchronous interface. Unlike SPI or I2C there is no need for a dedicated clock. The two devices just need to use the same transmission speed. The transmission speed is variable and dictates how many bits the bus can send each second (bits/s).
The data format is configurable too. Hence another way to measure transmission speed is the baudrate (bauds/s), where one baud is one symbol or character. So if one baud consists of 8 bits that means that a bitrate of 115200 bits/s equals 14400 bauds/s.
UART uses two data wires so in most cases the communication is full duplex (both directions at the same time). Additionally both UART devices need a wire to share the GROUND reference voltage. In sum that means that you only need three wires.
A UART device needs three pins to communicate. RX for reading, TX for transmitting and GND for GROUND reference.
Plug the RX pins of both devices into the TX pins of the other device. Connect both GND pins and your done with the hardware setup.
In theory you could even connect the RX pins of multiple devices into the TX pin of one device. That way, if you know what you are doing you can let one device broadcast the data to multiple devices. But the RX of any device can only be connected to one TX pin at a time.
You need to set both devices to the same baudrate. If it differs by more than 3% the data will be corrupted. Common baudrates are 4800, 9600, 19200 and 115200 among others. Additionaly both devices need to agree to the same data format and parity bit. The parity bit is a means to check the transmitted data for errors.
Whenever a device wants to transmit data it starts by sendig the start bit.
The idle state of the data wire is HIGH so the transmitter pulls it LOW for one clock cycle. Then it pulls the wire LOW for a 0 and HIGH for a 1 in the exact frequency of the baudrate. After each data frame it sends a parity bit if error checking is desired. Then it sets the Wire HIGH to signal the stop bit.
Advantages, Disadvantages and Applications
The most striking advantage is the simplicity of UART. Both software and hardware are extremely easy to set up. The variable speed means that you can keep power consumption very low. And of course the interface allows for full duplex communication.
Besides that the data can travel long ranges up to 1000 meters.
The interface is basically limited to two devices. Also there is no clock to control and change the transmission speed during the transmission. In most cases it is slower than for example SPI or I2C.
UART is very capable of sending smaller amounts of data. It is used by many GPS receivers, Bluetooth modules, Wireless communication systems or RFID based applications.
You can also use the interface to connect your Raspberry Pi to your Raspberry Pi Pico like we show in this video.
It is also performing well in long range applications where SPI and I2C are not an option.
Leave a Comment