Allow ordinary users to use the Raspberry Pi Sense HAT

Normally unless you are a super user you will get the following error message (or something similar) when you try to run a scripts that attempts to modify the Sense HAT display.

Traceback (most recent call last):
  File "./", line 55, in
    sense.set_pixel(x, y, r, g , b)
    File "/usr/lib/python2.7/dist-packages/sense_hat/", line 330, in set_pixel
    with open(self._fb_device, 'wb') as f:
IOError: [Errno 13] Permission denied: '/dev/fb1'

The key part of the error message is the bit I’ve highlighted – basically an ordinary user dosen’t have access to the device.

Fortunately there is a relatively easy solution. First we need to create a ‘udev’ rule that will give all members of the ‘video’ group access to the device, then we need to make the user a member of the ‘video’ group. Using a rule means that the permissions will be modified automatically every time the system starts.

To allow ordinary users to make use of the other sensors on the Sense HAT we will also need to install the ‘i2c-tools’ package and make the user a member of the ‘i2c’ group (this needs to be done after installing ‘i2c tools’, otherwise the group doesn’t exist).

To make the changes to the system we need to be running as ‘root’.

# su

First create the new ‘udev’ rule and add the user to the ‘video’ group.

# echo 'SUBSYSTEM=="fb1",GROUP="video",MODE="0660"' \
> >/etc/udev/rules.d/10-fb-permissions.rules
# udevadm control --reload-rules
# usermod -a -G video username

Then install ‘i2c-tools’ and add the user to the ‘i2c’ group.

# apt-get install i2c-tools
# usermod -a -G i2c username

Finally we need to ensure that the ‘i2c-dev’ module will be loaded when the system boots by checking that it is included in ‘/dec/modules’.

# vi /etc/modules

# /etc/modules: kernel modules to load at boot time.
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with “#” are ignored.
# Parameters can be specified after the module name.

If the ‘i2c-dev’ entry was missing we will need to reboot for the changes to take effect, otherwise we just need to logout and log back in again for the changes in group membership to take effect.

# reboot

Raspberry Pi is a trademark of the Raspberry Pi Foundation

This entry was posted in Hardware, Raspbian and tagged , . Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s