UART
Pros: Widely supported, allows two-way communication
Cons: Can't share communication lines, slower than SPI and I2C, and more susceptible to errors due to asynchronous transmission
General Information: UART
UART stands for Universal Asynchronous Receiver/Transmitter and is really just a fancy way of referring to a serial port. UART only requires two lines: a transmission line (TX) and a receiving line (RX).
TX: Used by the device to send data from the device.
RX: Used by the gateway to send data to the device
A UART Data Transmission
UART transmissions begin with a start bit, where the appropriate line (TX or RX) is pulled low by the sending party. Then, five to eight data bits are sent. The diagram above shows a scenario where eight bits are sent.
Following the data, an optional parity bit is sent, followed by one or two stop bits, where the sending module pulls the pin high.
For this protocol to work, the sender and receiver have to agree on a few things:
- The number of data bits that are sent with each packet (five to eight)
- The speed at which the data should be sent (the baud rate)
- Whether there is a parity bit after the data, and whether it is high or low
- The number of stop bits that will be sent at the end of each transmission