In this tutorial, you are going to learn firstly, about the UART protocol used in communication system. Secondly, we will also see various sensors using this protocol So, let us begin!
Contents:
- What is UART ?
- Why to choose UART protocol?
- More Features
- Sensors based on UART protocol
- Using in Arduino communication
What is UART ?
UART stands for Universal Asynchronous Receiver/Transmitter. It is a peripheral that is present inside a microcontroller. It’s function is to convert the incoming and outgoing data into the serial binary stream. The letter ‘A’ here stands for Asynchronous. This means there is no clock signal to synchronize or validate the data transmitted from transmitter and received by the receiver (Asynchronous Serial Communication). This is in contrast to Synchronous Serial Communication. As a result, it uses a clock signal that is shared between the transmitter and receiver in order to “Synchronize” the data between them.
UART transmits data which is organized into packets. Each packet contains 1 start bit, 5 to 9 data bits (depends), an optional parity bit, and 1 or 2 stop bits.
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.
Why to choose UART protocol?
Protocols like SPI (serial peripheral interface) and USB (Universal Serial Bus) are used for fast communication. So it is mostly used when high speed data is not required. For example, there are various embedded systems in which continuous data is not transmitted. In such scenario, this works best. It is a cheap communication device with a single transmitter/receiver. Most importantly, it requires a single wire for transmitting the data and another wire for receiving.
More Features
The UART performs serial-to-parallel conversions. The data is received from a peripheral device and parallel-to-serial conversion on data received from the CPU. The CPU can read it’s status at any time. The UART includes control capability and a processor interrupt system too. This can be tailored to minimize software management of the communications link.
The hardware for UART can be a circuit integrated on the microcontroller or a dedicated IC. This is contrast to SPI or I2C, which are just communication protocols. 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.
Sensors based on UART protocol
There are multiple sensors using the UART protocol. Some prominent ones are:
- Bluetooth Module: The HC-05/HC-06 modules are based on the USART protocol only. The Rx/Tx pins present in the sensor are joined with the Tx/Rx pins of the controller respectively. The Tx pin transmits Serial Data. The bluetooth receives everything and this pin gives it out as serial data. The Rx pin receives Serial Data. Every serial data given to this pin will be broadcast via Bluetooth.
- GPS module: It is used for navigation. The module simply checks its location on earth and provides output data which is longitude and latitude of its position. You can read more about it here.
- Particulate Sensor: This is used to measure the air quality and tells the PM2.5 or PM10. HPMA115s0-XXX is also one of these. It also uses the UART protocol. Read more about it here.
Using in Arduino communication
The Arduino is compatible with various communication protocols. We use I2C protocol sensors like the MPU 6050, SPI protocol sensors etc. The Arduino board and a computer or other devices use serial communication. Moreover, all Arduino boards have at least one serial port (also known as a UART or USART), and some have several.
You can use the Arduino environment’s built-in serial monitor to communicate with an Arduino board. Click the serial monitor button in the toolbar and select the same baud rate used in the call to begin()
. You can read more about it here.
With this I conclude the blog, I hope you will explore more in the topic. Feel free to write any query in the comment section. Happy Learning!