UART for Serial Console or HAT on Raspberry Pi 3

It seems the recently launched Raspberry Pi 3 behaves differently with regards to the UART interface on the GPIO header. In this guide I go through the steps I took to get the UART working for serial console or HAT communication.

I am assuming you are using a recent Raspbian Jessie image (2016-03-18 or more recent) on Raspberry Pi 3, that the file system has been expanded and that enough space is left for the software updates to be installed.

Let’s go!

Update Software

The first thing you’ll need to do is to ensure all software components are up-to-date.

Update the repository and upgrade the installed packages:

Update the firmware:

Reboot to apply the changes:

Enable UART

A new property has been introduced to enable the UART on the Pi. This property will put the core frequency to a minimum, ensuring stability. It’s possible to put the core frequency to maximum as well, assuming the power supply is powerful enough and the Pi 3 is properly cooled (heatsink!).

Enabling UART with minimum core frequency:

Enabling UART with maximum core frequency:

More information on this newly introduced property can be found here: https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=141195

Below are two screenshots: on the left, console before update, on the right, after the update and enable. The results are clearly better!

Screen Shot 2016-03-24 at 20.13.42 Screen Shot 2016-03-24 at 20.23.49

Disable Console

In case you would like to connect a HAT using the UART interface, it’s recommended to disable the console.

To disable the console, edit the following file as follows:

Reboot to apply the change:

You can verify something is being sent/received by the HAT’s UART with the commands below.

Set the baudrate of the interface, for example 57600:

Dump the data of the serial interface:

If you see data, your HAT’s UART should be working and can now be used in your script/application.

The screenshot below demonstrates my EnOceanPi HAT providing data to OpenHab using the GPIO’s UART:

IMG_1142 Screen Shot 2016-03-24 at 21.58.19

 

 

 

6 thoughts on “UART for Serial Console or HAT on Raspberry Pi 3”

  1. Frederick, do you know if it is possible to combine the e-paper interface and an application that uses the Serial port?

  2. Very interesting article, thanks :

    I followed all the steps, but when I give a try for “root@raspberrypi:~# sudo stty -F /dev/ttyS0 57600”

    I get following error message :
    “stty: /dev/ttyS0: Erreur d’entr?e/sortie”
    (in english, IO error).
    Would you have an idea why I get that ?

    Thanks,

Leave a Reply

Your email address will not be published. Required fields are marked *