-
Notifications
You must be signed in to change notification settings - Fork 37
How to Enable Serial Port hardware on the Raspberry Pi
Dr. Takeyuki Ueda edited this page Aug 21, 2019
·
4 revisions
The screen interface of Raspi-config command depend on it release version.
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
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.