A simple way to automatically turn your Raspberry Pi digital picture frame on and off at fixed times

Unless you want your digital picture frame on display 24/7, you must decide how to control the display power. My articles will show you a few ways, but the easiest for beginners is clock-controlled power management.

In Linux, this is done through the Cron Daemon, a process that runs in the background and triggers defined events at a specified time, as described in the crontab file.

In this article, I will explain how to set up the crontab and configure wake and sleep commands for your digital picture frame. I will also show a Python script for display power management.

Note: The vcgencmd command to turn a display on and off was recently retired. For Raspberry Pi OS Bookworm, I have updated the commands.

A Clockwork Raspberry

Tested with Raspberry Pi OS Bookworm Wayland (November 2024) and Raspberry Pi 4.

To turn off a digital picture frame, you deactivate the display. The computer itself, the Raspberry Pi, is never turned off.

Once turned off, there is no way of auto-awakening it as no battery powers a real-time clock (RTC) on the small board. But since its power consumption is only 2-3 Watts, it wouldn’t make much difference on your utility bill.

So, when a Raspberry Pi is powered on, it continuously checks for a trigger event—in our case, time. The table with the “wake-up” calls is kept in the crontab file.

To open the crontab, you type in a Terminal window

crontab -e

If you haven’t used crontab -e before, you will be asked which editor you want to use. I recommend #2, the nano editor.

A typical line in the crontab script to trigger a time-based event will look something like this:

00 07 * * 1-5 wlr-randr --output HDMI-A-1 --on

This turns on the digital picture frame screen every Monday to Friday at 7h00. The exact time syntax of the crontab is explained very well on the crontab.guru website, so I won’t go into many details here.

Eight days a week

Here is an example of a script that assumes that from Monday to Friday, the digital picture frame should be turned on at 7h, and on weekends at 8h. From Sunday to Thursday, bedtime is at 22h45, and from Friday to Saturday one hour later.

# Turn off display Sunday - Thursday at 22h45
45 22 * * 0-4 wlr-randr --output HDMI-A-1 --off
# Turn off display Friday - Saturday at 23h45
45 23 * * 5,6 wlr-randr --output HDMI-A-1 --off
# Turn on screen Monday - Friday at 7h00
00 07 * * 1-5 wlr-randr --output HDMI-A-1 --on
# Turn on screen Saturday - Sunday at 8h00
00 08 * * 6,0 wlr-randr --output HDMI-A-1 --on

The command to power off the screen is

wlr-randr --output HDMI-A-1 --off

and to power on, you put

wlr-randr --output HDMI-A-1 --on

Save the file with CTRL+O and exit with CTRL+X. You’re done!

You can add as many time triggers as you like in the crontab.

Powering down the monitor when not needed will save you electricity (about 20 Watts) and may extend the lifespan of your monitor. Others prefer to leave the display on to deter burglars or out of convenience, but that’s up to your preferences.

50 ways to control your display

There are many other methods of automatically controlling the power status of your digital picture frame display.

At home, we have installed a presence detection system. The Raspberry Pi knows when a person is at home based on the Wi-Fi presence of his/her iOS device. You can also try adding a motion sensor.

You can also geofence your home with smartphones and trigger action through IFTTT.

Conclusion

While crontab is an easy-to-write command to turn your screen on/off automatically, there is also a more modern alternative now with systemd timers. If your crontab system works fine, there is no need to change to systemd but if you are experiencing problems, have a look at my systemd timer article.

Was this article helpful?


Thank you for your support and motivation.


Scroll to Top