In this project we will interface UART with Raspberry pi using a C program. If you are new to UART protocol go through UART protocol theory of operation article before executing this project.
The setup requirement for this project is as given below:
Learn to develop software solutions for linux environment, implement requirements through real time projects and get required practical skills for software jobs
Along with your Raspberry Pi, you will need the following components for this project:
UART in Raspberry pi is used for Linux console output and Bluetooth purpose. Hence we need to enable the UART first before we try to communicate using UART. To configure UART open a terminal console and enter command "sudo raspi-config" and select option 5 Interfacing Options and then click on Finish as shown on the following picture.
After selecting Interfacing option enable UART by selecting the Serial option as shown below.
To confirm login shell to be accessible over serial select following option as NO.
Give option as yes when asked to enable serial hardware as shown in following figure.Click ok in the following figure. Once the above configuration changes are made, reboot the raspberry pi. After reboot try a command "ls -l dev" and you should see the uart is listed as shown in figure below.
Raspberry Pi 3 board has pin 8(GPIO14) and pin 10(GPIO15) used as UART Tx and UART Rx respectively. Following picture shows the pins we will be using in this project.
Make sure that PI is NOT powered on. You should connect the pin 6(GND) to the GND pin, pin 8(UART0 TX) to the GND pin of TTL to USB converter module. Connect other end of the TTL to USB converter module to one of the USB port port in your computer. Go to windows start -> device manager and check that the converter module is recongnized. If it is not recognized, right click on the device and follow the direction to get the driver for the module from internet. Once all the three connections are made between Raspberry pi and TTL - USB converter module, you power on the pi and develop the uart program as explained in the next section.
The schematic diagram for this project is shown in the following picture.