Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kohlerdominik/fc169238df94a33f8a05c65da57aaee2 to your computer and use it in GitHub Desktop.
Save kohlerdominik/fc169238df94a33f8a05c65da57aaee2 to your computer and use it in GitHub Desktop.
Enable Serial Interface via UART for the Raspberry PI
#!/bin/bash
# # # # # # # # # # # # # # # # # # #
# Enable Serial Interface via UART #
# # # # # # # # # # # # # # # # # # #
# Dominik Kohler @ 19.11.2018
# Tested on Raspbian Stretch (9.4)
# Disabling Linux's use of console UART (https://www.raspberrypi.org/documentation/configuration/uart.md)
sed -i -e 's/console=serial0,115200 //g' /boot/cmdline.txt
# Disable Bluetooth and restore UART0/ttyAMA0 over GPIOs 14 & 15.
printf "\ndtoverlay=pi3-disable-bt\n" >> /boot/config.txt
# Disable Systemd service that initialises the modem which uses the UART usually.
systemctl disable hciuart
echo "Reboot is required for changes to take effect"
# Configure the UART interface to 9600/8/1. Output all received data in terminal (end with CTRL+C)
# stty -F /dev/ttyAMA0 9600 min 1 time 0 -brkint -icrnl -imaxbel -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke
# cat /dev/ttyAMA0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment