

If you prefer keeping the Bluetooth interface, and use the mini-uart, then you’ll use the device named /dev/ttyS0.Īnyway, once you’ve setup that, you need to add your user to the “dialout” group: sudo adduser your_username dialout. Once you’ve done this, you will be able to use the device named /dev/ttyAMA0. Then reboot and you should be able to use the real UART. To use the real UART for your RX/TX pins (this will disable Bluetooth), add dtoverlay=pi3-disable-bt into your /boot/config.txt file, and remove anything that looks like console=serial0,115200, console=tty1 in your /boot/cmdline.txt file. You can have a complete explanation here, but basically it means that by default, the UART you’re using has a not-so-great clock and performance. By default, from Raspberry Pi 3 and later, the “true” hardware UART, named PL011, has been re-wired for Bluetooth, letting a mini-uart available for Serial communication over UART pins.

Hardware/Serial ports (RX/TX pins)Ī quick warning before you continue. Add your user to the “dialout” group: sudo adduser your_username dialout. This concerns USB devices that appear as /dev/ttyUSB0, /dev/ttyACM0, etc. I2CĪdd user to group “i2c”: sudo adduser your_username i2c. SPIĪdd user to group “spi”: sudo adduser your_username spi. Here is a non-exhaustive list of the groups you’ll need to belong to if you need to use the associated hardware interface.Īlso check out this Raspberry Pi pin description to know which hardware pins are related to which interface. Groups may vary depending on what hardware interface you want to use.
#RASPBERRY PI LIST SERIAL PORTS HOW TO#
You just saw how to add a user to a hardware group, and more specifically for SPI. Removing user `your_username' from group `spi'. Tadaa, spi is here! Note that in order to work, you may have to reboot your Pi (or re-login).Īlso, at any point, if you want to remove a user from a group – for example you want to remove access for a certain user without having to completely disable a hardware interface, you can do that with deluser: $ sudo deluser your_username spi Your_username : your_username adm cdrom sudo dip video plugdev input lpadmin gpio i2c spi sambashare Now, if we check in which group your user belongs to: $ groups your_username To add a user in a group, use adduser with sudo: $ sudo adduser your_username spiĪdding user `your_username' to group `spi'. Here you can notice that your user is not in the “spi” group, which can lead to “Permission denied” errors when trying to execute a program using SPI. If you type groups without any argument, you’ll see all groups. Your_username adm cdrom sudo dip video plugdev input lpadmin sambashare spi i2c gpio Let’s see what are all groups available on your Raspberry Pi. It means that you have access to the I2C functionalities (which have been previously enabled).

In this example, you can see that your user has access to the “i2c” group. Your_username : your_username adm cdrom sudo dip video plugdev input lpadmin gpio i2c sambashare Let’s assume that your username is simply “your_username”. If you’re not running your programs as root (which you should not do anyway), you may encounter permission issues at this point.įirst, run the groups command line tool to see in which groups you belong. Once a specific hardware functionality is enabled, you may have to do an additional step in order to use it. If you want to disable a specific hardware interface, you just need to comment the line and reboot again. Don’t forget this part, this will save you from huge headaches! Once you have changed a setting in the /boot/config.txt, you must reboot your Pi in order to apply the change. Uncomment the line dtparam=uart0=on or set enable_uart=1. Uncomment the line dtparam=spi=on (if “off”, change to “on”). Uncomment the line dtparam=i2c_arm=on (if “off”, change to “on”). You are learning how to use Raspberry Pi to build your own projects?Ĭheck out Raspberry Pi For Beginners and learn step by step. If I2C, SPI or UART are not enabled, you simply won’t be able to do anything.įind the file /boot/config.txt and edit it with admin rights (use “sudo”): Raspberry Pi hardware permissions: conclusionįirst of all you have to enable hardware in boot config files, before you even think about permissions.Give hardware permissions with udev rules.
