Controlling the backlight of the Official Raspberry Pi 7″ Touchscreen

I have Raspberry Pi 3 running a connected Wall Display from The software runs in a browser window. It is a very simple setup and well described in this article: My Raspberry has a nice enclosure as well:

The only thing that annoyed me was that I couldn’t find a way do shut down the Pi 7″ Touchscreen for the night. The way of shutting down the screen that was described is turning on and off an HDMI monitor with a script. That does not work for my Pi Touchscreen because it is not connected though HDMI but by FPC flatcables:

With the help of this blog I was able to figure a way out that fits best my needs and gives me control over the lcd’s backlight.

I made a script and put it in /home/pi/display, you can use the command “sudo /home/pi/display/” to create and edit the file with Nano, this is a very easy editor, just copy the following lines into the file:


# turning on and off the backlight lcd:

case $1 in
                echo 1 > /sys/class/backlight/rpi_backlight/bl_power

                echo 0 > /sys/class/backlight/rpi_backlight/bl_power

                echo "Usage: $0 on|off" >&2
                exit 2


exit 0

After editing you have to give the script execute rights with the command “sudo chmod +x /home/pi/display/

You might want to test the script in this fase. What I recommend to do is to login from another terminal (than the on Pi, it is hard to test with a black screen I guess:-)) with SSH and then test the script with the commands:

sudo /home/pi/display/ off (to turn the backlight off)
sudo /home/pi/display/ on (to turn, yeah right:-))

What I have done additionally is editing the Pi’s crontab. The crontab controls planned events. You can edit the crontab with the following command:

sudo crontab -e (remember the ‘sudo’, otherwise you will be editing your personal crontab and that is not allowed to control the lcd backlight!)

Put the following code in your crontab if you would like the screen to be dark from 23:59 till 07:30:

# Turn lcd display OFF (23:59/11:59pm)
59 23 * * * /home/pi/display/ off

# Turn lcd display ON (07:30/7:30am)
30 7 * * * /home/pi/display/ on

After leaving the editor the crontab will be re-loaded and you are good to go. Happy tinkering!



No comments yet.