Basics of UART Communication
Basics of UART Communication
SEARCH …
EMAIL ADDRESS
SUBSCRIBE
Remember when printers, mice, and modems had thick cables with those
huge clunky connectors? The ones that literally had to be screwed into
your computer? Those devices were probably using UARTs to communicate
with your computer. While USB has almost completely replaced those old
cables and connectors, UARTs are definitely not a thing of the past. You’ll find
UARTs being used in many DIY electronics projects to connect GPS modules,
Bluetooth modules, and RFID card reader modules to your Raspberry Pi,
Arduino, or other microcontrollers.
One of the best things about UART is that it only uses two wires to transmit
data between devices. The principles behind UART are easy to understand, but
if you haven’t read part one of this series, Basics of the SPI Communication
Protocol, that might be a good place to start.
s-IEC 61850-104 Gateway - Substation
ol Converter
INTRODUCTION TO UART COMMUNICATION OPEN
https://www.circuitbasics.com/basics-uart-communication/ 1/17
10/9/23, 12:46 PM Basics of UART Communication
When the receiving UART detects a start bit, it starts to read the incoming
bits at a specific frequency known as the baud rate. Baud rate is a measure of
the speed of data transfer, expressed in bits per second (bps). Both UARTs
must operate at about the same baud rate. The baud rate between the
transmitting and receiving UARTs can only differ by about 10% before the
timing of bits gets too far off.
Both UARTs must also must be configured to transmit and receive the same
data packet structure.
https://www.circuitbasics.com/basics-uart-communication/ 2/17
10/9/23, 12:46 PM Basics of UART Communication
UART transmitted data is organized into packets. Each packet contains 1 start
bit, 5 to 9 data bits (depending on the UART), an optional parity bit, and 1 or 2
stop bits:
START BIT
The UART data transmission line is normally held at a high voltage level when
it’s not transmitting data. To start the transfer of data, the transmitting UART
pulls the transmission line from high to low for one clock cycle. When the
receiving UART detects the high to low voltage transition, it begins reading the
bits in the data frame at the frequency of the baud rate.
DATA FRAME
The data frame contains the actual data being transferred. It can be 5 bits up to
8 bits long if a parity bit is used. If no parity bit is used, the data frame can be 9
bits long. In most cases, the data is sent with the least significant bit first.
PARITY
Parity describes the evenness or oddness of a number. The parity bit is a way
for the receiving UART to tell if any data has changed during transmission. Bits
can be changed by electromagnetic radiation, mismatched baud rates, or long
distance data transfers. After the receiving UART reads the data frame, it
counts the number of bits with a value of 1 and checks if the total is an even or
odd number. If the parity bit is a 0 (even parity), the 1 bits in the data frame
should total to an even number. If the parity bit is a 1 (odd parity), the 1 bits in
the data frame should total to an odd number. When the parity bit matches
the data, the UART knows that the transmission was free of errors. But if the
parity bit is a 0, and the total is odd; or the parity bit is a 1, and the total is even,
the UART knows that bits in the data frame have changed.
STOP BITS
To signal the end of the data packet, the sending UART drives the data
transmission line from a low voltage to a high voltage for at least two bit
durations.
https://www.circuitbasics.com/basics-uart-communication/ 3/17
10/9/23, 12:46 PM Basics of UART Communication
2. The transmitting UART adds the start bit, parity bit, and the stop bit(s) to the
data frame:
3. The entire packet is sent serially from the transmitting UART to the receiving
UART. The receiving UART samples the data line at the pre-configured baud
rate:
4. The receiving UART discards the start bit, parity bit, and stop bit from the
data frame:
5. The receiving UART converts the serial data back into parallel and transfers it
to the data bus on the receiving end:
https://www.circuitbasics.com/basics-uart-communication/ 4/17
10/9/23, 12:46 PM Basics of UART Communication
No communication protocol is perfect, but UARTs are pretty good at what they
do. Here are some pros and cons to help you decide whether or not they fit the
needs of your project:
ADVANTAGES
The structure of the data packet can be changed as long as both sides
are set up for it
DISADVANTAGES
The baud rates of each UART must be within 10% of each other
And as always, let us know in the comments if you have questions or anything
else to add! If you liked this article and want to see more like it, be sure to
subscribe- we send out an email when ever we publish new posts.
SHARE:
RELATED POSTS
79 COMMENTS
https://www.circuitbasics.com/basics-uart-communication/ 5/17
10/9/23, 12:46 PM Basics of UART Communication
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
https://www.circuitbasics.com/basics-uart-communication/ 7/17
10/9/23, 12:46 PM Basics of UART Communication
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
https://www.circuitbasics.com/basics-uart-communication/ 8/17
10/9/23, 12:46 PM Basics of UART Communication
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
I didnt get from where that allowed difference of 10% came from.
Can you please explain!!!
REPLY
REPLY
Thank you soo much.. Thanks a ton. Really U ppl had done a
great job. Now seriously I understood the working principle,
data transmission of bits and everything without any doubt.
Thanks again and again. Hope you upload more and more
sessions and concepts like this.
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
https://www.circuitbasics.com/basics-uart-communication/ 10/17
10/9/23, 12:46 PM Basics of UART Communication
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
https://www.circuitbasics.com/basics-uart-communication/ 11/17
10/9/23, 12:46 PM Basics of UART Communication
REPLY
REPLY
REPLY
REPLY
REPLY
https://www.drurylandetheatre.com/
REPLY
REPLY
REPLY
https://www.circuitbasics.com/basics-uart-communication/ 12/17
10/9/23, 12:46 PM Basics of UART Communication
REPLY
REPLY
REPLY
REPLY
REPLY
Ref: https://www.cypress.com/file/132486
REPLY
https://www.circuitbasics.com/basics-uart-communication/ 13/17
10/9/23, 12:46 PM Basics of UART Communication
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
REPLY
https://www.circuitbasics.com/basics-uart-communication/ 14/17
10/9/23, 12:46 PM Basics of UART Communication
REPLY
REPLY
This is a little bit misleading and poorly written. Parity bit is not 0
on even parity and 1 in odd parity. Parity bit can be 1 or 0
depending on the situation. In case of even parity, the total
number of ‘1’ bits, including the parity bit, should be even. In
contrast, in odd parity, the total number of ‘1’ bits, including parity
bit, should be odd. So parity bit is either ‘1’ or ‘0’ to satisfy the
requirement I described before. An example always makes things
more clear.
REPLY
https://www.circuitbasics.com/basics-uart-communication/ 15/17
10/9/23, 12:46 PM Basics of UART Communication
REPLY
REPLY
REPLY
LEAVE A REPLY
Your email address will not be published. Required fields are marked *
COMMENT
Save my name, email, and website in this browser for the next time I comment.
For security, use of Google's reCAPTCHA service is required which is subject to the Google
Privacy Policy and Terms of Use.
POST COMMENT
https://www.circuitbasics.com/basics-uart-communication/ 16/17
10/9/23, 12:46 PM Basics of UART Communication
https://www.circuitbasics.com/basics-uart-communication/ 17/17