Raspberry Pi Serial Port Uart
Default Raspberry PI 3 serial port aliases. Default Raspberry PI 2 serial port aliases. So where possible refer to the serial port via it’s alias of “serial0” and your code should work on both Raspberry Pi 3 and other Raspberry Pi’s. Disabling the Console. If you are using the serial port for anything other than the console you need to.
My Pi3 serial console produces rubbish and fails to respond to the keyboard.
3 Answers
This answer is still correct, and explains in more detail the nature of the changes, but most users of current Raspbian should just run sudo raspi-config
Select Interfacing Options / Serial
then specify if you want a Serial console (probably no) then if you want the Serial Port hardware enabled (probably yes). Then use /dev/serial0
in any code which accesses the Serial Port.
The BCM2837 on the Raspberry Pi3 , Pi3B+, PiZeroW has 2 UARTs (as did its predecessors), however to support the Bluetooth functionality the fully featured PL011 UART was moved from the header pins to the Bluetooth chip and the mini UART made available on header pins 8 & 10.
This has a number of consequences for users of the serial interface.
The /dev/ttyAMA0
previously used to access the UART now connects to Bluetooth.
The miniUART is now available on /dev/ttyS0
.
In the latest operating system software there is a /dev/serial0
which selects the appropriate device so you can replace /dev/ttyAMA0
with /dev/serial0
and use the same software on the Pi3 and earlier models.
Unfortunately there are a number of other consequences:-
There is no support for parity and the throughput is limited, but the latter should not affect most uses.
There is one killer feature 'Baudrate derived from system clock' which makes the miniUART useless as the this clock can change dynamically e.g. if the system goes into reduced power or in low power mode.
Raspberry Pi Uart Pins
Modifying the /boot/config.txt
removes this dependency by adding the following line at the end:-
This fixes the problem and appears to have little impact. The SPI clock frequency
and ARM Timer
are also dependent on the system clock.
For some bizarre reason the default for Pi3 using the latest 4.4.9 kernel is to DISABLE UART. To enable it you need to change enable_uart=1
in /boot/config.txt
. (This also fixes the core_freq
so this is no longer necessary.)
Finally if you don't use Bluetooth (or have undemanding uses) it is possible to swap the ports back in Device Tree. There is a pi3-miniuart-bt
and pi3-disable-bt
module which are described in /boot/overlays/README
.
finally this got work for my pi3 (os: debian jessie)
please follow these 6 steps carefully.
Step 1 - Install Raspbian Jessie onto a SD card and boot the Pi when connected to a network Login via terminal or desktop and shell Configure the system with:
Expand filesystem and enable serial on advanced page, exit and reboot.
Step 2 -this won't necessary if you have jessie new release Update the system with:
Step 3 - Device Tree settings as below:
Add device tree to /boot/config.txt to disable the Raspberry Pi 3 bluetooth.
Add at the end of the file
*if you want to change the blutooth to miniuart port(bad)
*if you want to disable the blutooth(good)
Exit the editor saving your changes.
Step 4 - reboot the pi
step 5 -
a)to disable the Serial Console edit the file using
remove the word phase 'console=serial0,115200
' or 'console=ttyAMA0,115200
'
Exit and save your changes
Parallel Port
b)to Enable the Serial Console edit the file using
Change the file to the following:
Exit and save your changes
Usb Uart Raspberry Pi
Step 6 - reboot the pi
-----------------that's all,have fun-------------------------------
Naseer's answer is correct but a bit elaborate if you just flashed the latest rasbian. All I needed to do, is just to add the following line to my config.txt (from e.g. windows where you plug in the SD card on the fat32 partition):
Then plug it in, and the pi will directly print stuff on the console pins.
protected by Community♦Nov 6 '16 at 15:04
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?