We had an exciting first week of March this year, yeah playing with the all new Raspberry Pi 3. We had the Pi 3, and we were selling it to all Pi enthusiasts out there. And one day, we got a call. A frustrated customer, he was unable to use the UART of his Pi 3. Thats right! Without a proper work around, UART on the GPIO header wont function well.
The previous versions of Raspberry Pi had UART0 brought out on the GPIO header. But the design was changed with Raspberry Pi 3, which features UART1 on the GPIO header while UART0 is dedicated for Bluetooth. And therefore, the UART on GPIO header will be available at /dev/ttyS0 instead of /dev/AMA0. To meet with with change, we will have to configure the OS accordingly.
Open the LX teminal and type:
dmesg | grep tty
This command will list the available UART modules, as shown in the figure:
The list will show, ttyS0 – UART corresponding to the GPIO header.
To operate the GPIO UART at the correct baud rate, enter sudo nano /boot/config.txt in the terminal and add the two lines
Save the file and reboot the Pi.
The GPIO UART now operates at the correct baud rate, and is
available at /dev/ttyS0, and NOT /dev/ttyAMA0 like before.
So while writing the code in python has to changed accordingly:
port = serial.Serial(“/dev/ttyS0″, baudrate=9600, timeout=1)
So what make the difference here? Hows anything different with UART1 of BC2835/6. This is how it is:
- Unlike UART0, UART1 is dependent on Core Clock Frequency
- Unlike UART0, UART1 has smaller FIFOS
When the core clock changes, the baud rate will also change!