Raspberry Pi UART communication using C program

In: Project Code: PL000010
Share

In this project we will interface UART with Raspberry pi using a C program. If you are new to UART protocol go through article before executing this project.

Complete this project and update to consider it for requirements and earn certificate.

project diagram

Project Steps


Online courses related to this project


Course description

Learn to develop embedded systems, interfacing electronic peripherals through real time projects and get required practical skills for software jobs



Course description

Learn to develop software solutions for linux environment, implement requirements through real time projects and get required practical skills for software jobs

Required components


Along with your Raspberry Pi, you will need the following components for this project:

Raspberry Pi UART Information


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.

course thumb
Configuring UART on Raspberry Pi

After selecting Interfacing option enable UART by selecting the Serial option as shown below.

course thumb
Enable UART on Raspberry Pi

To confirm login shell to be accessible over serial select following option as NO.

course thumb
Confirm login accessible over serial on Raspberry Pi

Give option as yes when asked to enable serial hardware as shown in following figure.

course thumb
Enable serial hardware on Raspberry Pi
Click ok in the following figure.
course thumb
UART confirmation on Tx and Rx pin on Raspbery pi
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.
course thumb
UART listed post configuration on Raspberry Pi

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.

course thumb
Pin diagram of Raspberry Pi.

Project Schematic diagram


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.

course thumb
Project setup diagram.

Prepare program, compilation, output


Subscribe online courses

Subscribe below to unlock project and earn certificates for software jobs

Subscribe

Looking for a new project? Write and upload your project information .
Share


Schedule a project

Embedded Systems Projects

Linux Software Projects

Articles



 Online Certificate Courses

 Test your skills:online tests

 C Programming

 Python Programming

 Linux Software

 Quantitative Aptitude