Putting RaspberryPi Monitor to Sleep (DPMS)

posted Oct 10, 2018, 3:54 AM by Tom Pedersen   [ updated Oct 15, 2018, 3:01 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.

The fix involves editing a couple of key configuration files, always a good policy to make a backup copy before type-o'ing.  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)

    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 RPI's that run a 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.