Skip to main content

A Python module for controlling power and brightness of the official Raspberry Pi 7" touch display.

Project description

Travis CI status Code health Issues Version License Documentation

A Python module for controlling power and brightness of the official Raspberry Pi 7” touch display.



  • Change the display brightness smoothly or abrupt
  • Set the display power on or off
  • Get the current brightness
  • Get the maximum brightness
  • Get the display power state (on/off)
  • Command line interface
  • Graphical user interface


  • A Raspberry Pi including a correctly assembled 7” touch display v1.1 or higher running a Linux-based OS
  • Python 2 or 3
  • Optional: pygobject for the GUI, is likely to be already installed on a recent Raspbian


  • Install from PyPI using:

    pip install rpi_backlight
  • or clone this repository and install by:

    git clone
    cd rpi-backlight
    sudo python3 install

Note: You may need to edit the backlight rules file in order to run the code:

sudo nano /etc/udev/rules.d/backlight-permissions.rules

Insert the line:

SUBSYSTEM=="backlight",RUN+="/bin/chmod 666 /sys/class/backlight/%k/brightness /sys/class/backlight/%k/bl_power"



Example in a Python shell:

>>> import rpi_backlight as bl
>>> bl.set_brightness(255)
>>> bl.set_brightness(20, smooth=True, duration=3)
>>> bl.get_max_brightness()
>>> bl.get_actual_brightness()
>>> bl.get_power()
>>> bl.set_power(False)

NOTE: Code using set_ functions of this library has to be run as root, e.g. sudo python , if the permissions for changing the backlight were not changed as described in the installation section!


Open a terminal and run rpi-backlight as root:

$ rpi-backlight -b 255
$ rpi-backlight -b 20 -s -d 3
$ rpi-backlight --max-brightness
$ rpi-backlight --actual-brightness
$ rpi-backlight --power
$ rpi-backlight --off


Open a terminal and run rpi-backlight-gui as root.

Graphical User Interface


Yay, this list is currently empty! Feel free to add ideas here.


The source code and all other files in this repository are licensed under the MIT license, so you can easily use it in your own projects.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
rpi_backlight-1.8.1.tar.gz (4.9 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page