Putting RaspberryPi Monitor to Sleep (DPMS)

posted Oct 10, 2018, 3:54 AM by Tom Pedersen   [ updated Jan 1, 2022, 4:42 AM ]
http://ventures.tpedersen.net/images/black_diamond_icon.gif
I recently stumbled upon a fix for a longstanding Raspberry PI annoyance - getting the monitor into powersave mode after a period of idle time.  Here's a quick tweak that seems to work fine on native HDMI and VGA (via adapter*) monitors.  Hopefully helpful to others.

I've played with Linux Power Management commands, utilities, screen savers and such in attempts to get Pi's to turn off (standby) monitors when idle.  I recently hit upon a Raspberry Pi config option that seems to do the trick - not really sure when/where it appeared, but it does switch off the HDMI when Display Power Management (DPMS) is triggered, as opposed to simply blanking the screen.  Works on Raspbian Stretch, have not tested previous versions.

Dec 2021 FINAL Update - I STILL Use this!  Procedure below has been moved to tech.tpedersen.net/raspberry-pi/pi-in-the-sky/putting-raspberry-pi-monitor-to-sleep-dpms so I don't lose it when Google shuts down this site!

Jun 2020 Update - In spite of Buster Update noted below ... I STILL manually adjust /boot/config.txt & /boot/cmdline.txt to get HDMI to standby.  Tested again today using 2020-05-27-raspios-buster-lite-armhf.  Yeeesh!

Feb 2020 Update - Looks like it's included in latest Buster Update.  Screen Blanking under Advanced Options of Raspi-Config.

Nov 2019 Notes - RPI 4 is fixed (or darn close).  The Open Issue shows progress - Seems to work for me.  May not be in latest release, but coming soon!  Also - noticed that boot.txt and cmdline.txt were overwritten when I upgraded an RPI from stretch to buster ... had to redo blanking

Sept 2019 Note - hdmi_blanking doesn't appear to be implemented on RPI 4 yet.  Details here.

------

Oct 2018 (Original Post)

The fix involves editing a couple of key configuration files - as always remember to make a backup copies before
type-o'ing in these files!  
Use sudo to edit files in boot partition *and* be careful!
  1. Edit /boot/config.txt (RPi's main System Config File

    Add the following line to force HDMI output to switched off when DPMS is triggered.  This config option was not explicitly defined in my Raspbian (Stretch) config.txt - apparently defaults to 0/off.  

    hdmi_blanking=1

    I added this below hdmi_mode in config.txt, but it probably doesn't matter.  See complete details in https://www.raspberrypi.org/documentation/configuration/config-txt/video.md.  There are some notes/considerations.

  2. Make sure Screen Savers are installed/configured to take advantage of hdmi_blanking.  

    For Console Mode (no Desktop UI) set console blanking ...

    Check current setting of consoleblank kernel parameter, it sets the inactivity time. 

    $ cat /sys/module/kernel/parameters/consoleblank
    0

    Edit (sudo) /boot/cmdline.txt to set time in seconds or zero (0) to disable screen blanking in console mode

    Carefully add the string "consoleblank=<numsec>" to /boot/cmdline.txt - MUST be a single line text file like this:

    $ cat /boot/cmdline.txt

    dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 consoleblank=300 root=/dev/mmcblk0p7 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

    For Desktop GUI set Display Power Management (DPMS) via screensaver or power manager applications - you may need to install these.   

    Screensaver:

    sudo apt-get install xscreensaver

    Power Manager:

    sudo apt-get install xfce4-power-manager

    See RPI Screensaver doc @ https://www.raspberrypi.org/documentation/configuration/screensaver.md for complete details.  

  3. Reboot and check your work!


As they say in IT - Works for me!  Hope it works for others too.  

Couple of random notes:

---------------

* T. Pedersen Ventures is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.com.