Turning Off a Raspberry Pi 5 Screen and Backlight with Debian Bookworm

The Simple Goal

I set out with a simple goal for my Raspberry Pi 5: to have the HDMI-connected screen and its backlight automatically turn off at night and come back on in the morning. Little did I know, this straightforward task would lead me down a path of unexpected twists and turns.

The Early Stages

Initially, my Raspberry Pi didn’t have any specific display driver settings enabled in /boot/config.txt. My first attempts involved basic commands:

  • Using xset: I tried xset dpms force off to blank the screen. It worked for the screen but left the backlight on, shining bright.
  • Switching to xrandr: Next, I used xrandr --output HDMI-1 --off. This turned off the screen momentarily, but the backlight remained an issue.

Exploring Further

I thought maybe ddcutil could give me direct control over the monitor’s settings. However, my setup didn’t support it, lacking the required /dev/i2c devices.

The Driver Discovery

Trying Fake KMS

In a bid to address the backlight problem, I enabled the Fake KMS driver (dtoverlay=vc4-fkms-v3d) in /boot/config.txt. But to my dismay, it didn’t turn off the backlight.

Success with Full KMS

The turning point came when I switched to the Full KMS driver (dtoverlay=vc4-kms-v3d). This change finally allowed me to control not just the screen but also the elusive backlight.

The Final Setup

Simplifying Daily Use

To make things easier, I added aliases to my .profile:

alias mon='DISPLAY=:0 xrandr --output HDMI-1 --auto'
alias moff='DISPLAY=:0 xrandr --output HDMI-1 --off'

Automating the Routine

I set up cron jobs to manage the screen without manual intervention:

# Commands to turn off the monitor in the evening
0 22 * * * DISPLAY=:0 xrandr --output HDMI-1 --off
0 23 * * * DISPLAY=:0 xrandr --output HDMI-1 --off
0 24 * * * DISPLAY=:0 xrandr --output HDMI-1 --off
# Command to turn on the monitor in the morning
0 8 * * * DISPLAY=:0 xrandr --output HDMI-1 --auto

In Conclusion

This experience was more than just a tech task; it was a lesson in the nuances of Raspberry Pi configurations. The switch to the Full KMS driver was a key moment, enabling complete control over both the screen and the backlight.

Leave a Reply