Skip to content

How to Enable Serial Port hardware on the Raspberry Pi

Dr. Takeyuki Ueda edited this page Aug 21, 2019 · 4 revisions

By raspi-config command

The screen interface of Raspi-config command depend on it release version.

RASPBIAN STRETCH 2018-06-27 Release:

By editing /boot/config.txt file

Add the line enable_uart=1 to the end of /boot/config.txt file as follows:


# Uncomment this to enable the lirc-rpi module
#dtoverlay=lirc-rpi

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

# ↓↓↓↓↓ Add this line ↓↓↓↓↓
enable_uart=1

Then, reboot to enable this setting as follows:

sudo reboot

Following shell script add the line to end of /boot/config.txt file and ask "Would you like to reboot now?". Actually, this is bottom half of setup.sh script.

sudo sed -i "s/^enable_uart=.*/enable_uart=1/" /boot/config.txt
read -p "Would you like to reboot now?  (y/n) :" YN
if [ "${YN}" = "y" ]; then
  sudo reboot
else
  exit 1;
fi

The side effect difference.

As reported issue #13 by joshuajon, above 2 methods have a different side effect for permissions of opened serial ports as follows:

  • By raspi-config command: The serial ports are opened with permission crw-rw-rw- 1 root dialout
  • By editing /boot/config.txt file: The serial ports are opened with permission crw--w---- 1 root tty

So, if you would use it without root permission, the former might be comfortable.