In Raspberry PI 3 & 4 the physical UART at GPIO14/GPIO15 is disabled.

In new machines the mapping is as follows.

/dev/ttyAMA0 -> Bluetooth
/dev/ttyS0 -> GPIO serial port   (referred to as the “mini uart”) disabled by default.

The powerful ttyAMA0 is assigned to Bluetooth & the limited frequency ttyS0 is assigned to UART.

Board pin 8 (GPIO14)  Tx
Board pin 10 (GPIO15) Rx

older Raspberry Pi it will point to the hardware UART and /dev/ttyAMA0


In this post , let us see how to enable UART and then overcome the Permission denied problem by swapping the ttyAMA0 & ttyS0.



While connecting the GSM with RPI use level shifter, as the TTL level of PI is 3.3 volt & that of GSM is 5v.

The Tx of PI (physical pin 8) goes directly to Rx of GSM. As GSM accepts 3.3v as High, you can connect this straight .

But the Rx (physical pin 10) pin needs alevel shifter before connecting to Tx of GSM

A simple 1k resistor in series and a 2k2 to GND will solve the purpose.


To enable the serial0 edit config.txt file using nano editor.


Navigate to the end of file and add


ctrl+x & Yes to save the file


use command

ls –l /dev

to read the devices.You can see serial0 is now enabled and mapped to ttyS0.

Image 4

Open picocom to communicate with GSM

picocom –baud 9600 /dev/ttyS0

Permission is Denied.



You can change permissions with sudo chmod command.But on next reboot this will change.

Also assigning groups dialout & tty to user PI does not help.

Image 2

In Raspberry Pi , you can use the serial port as a terminal to log in.
Even if you don’t have a network connection,you can connect to another computer via their serial ports and run a terminal software like putty  on the other computer to get a login prompt.

By default the Raspberry Pi uses the serial port for this “console” login
and via a software service called “getty”.

if we want to use the serial port to get data from a GPS or GSM, we need to disable
the console login so that gsm/gps alone get control of the port.

use the following commands

sudo systemctl stop serial-getty@ttyS0.service
sudo systemctl disable serial-getty@ttyS0.service

First command is to STOP the service of getty & the second one disables it.

Image 5


Finally Remove the console service by editing cmdline.txt




remove the line:


and save , reboot for changes to take effect.





Image 6


To use BLUETOOTH add the following line to the /boot/config.txt

sudo nano /boot/config.txt



Add this line at the end




Now mini uart is assigned to Bluetooth function.



After reboot you can check the devices

ls –l /dev

to see serial0 is assigned to ttyAMA0 & serial1 to ttyS0


Image 82

Install putty serial terminal .






open putty

Select SERIAL & feed in host as


& BAUD RATE 9600




pUTTY Terminal opens where we can test the GSM AT Commands.



Now the UART is mapped to ttyAMA0 as in older machines of PI and old python codes will work without any change.

Video support :