UART Port Usage on Raspberry Pi

UART Brief

TxD = BCM pin 14
RxD = BCM pin 15

Default inputs


Preventing Linux from claiming the UART port


Run sudo raspi-config and check if it has the option advanced options -> serial. If it has, set it to disabled and you’re done.


Enable uart in /boot/config.txt

In order to avoid manual step 5 and some issues that might occur with port ttyAMA0 not being found (/dev/ttyAMA0 being absent) you can set enable_uart=1 in /boot/config.txt, which seems to bring back /dev/ttyAMA0 and ports 15+16 are now in ALT0 state after reboot.

Good read:


#include <stdio.h>
#include <wiringPi.h>
#include <wiringSerial.h>
#include <errno.h>
#include <string.h>
#include <signal.h>

// 1. Please make sure /boot/config.txt has "enable_uart=1" set, this is to use the alternative UART, since main UART is used by Bluetooth by default
// 2. raspi-config should have serial option disabled
// 3. "gpio readall" should show ALT5 option for TX and RX

int main ()
 printf ("UART Test Programe\n") ;

 int fd;

 printf ("Pin mode Set\n") ;

 if ( (fd = serialOpen("/dev/serial0",9600)) < 0 )
 fprintf (stderr, "Unable to open serial device: %s\n", strerror (errno));
 return 1;

 if ( wiringPiSetupGpio() == -1 )
 fprintf (stdout, "Unable to start wiringPi: %s\n", strerror(errno));
 return -1;

 printf("I SURVIVED11\n");

 int counter = 0;




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s