Toggle on and off gpio display on raspberry pi

I have a 7" gpio display for a raspberry pi and am using it as a display for home assistant. I would like a way to be able to turn it on and off at times like night time or when I am not at home with out shutting down the raspberry pi. I have tried just switching the display power on and off, but the display does not come back on after this until the pi is rebooted.

If you want to turn off the display without shutting down the Raspberry Pi and have it turn back on when needed, you can try the following approach:

  1. Use HDMI CEC: Check if your display supports HDMI CEC (Consumer Electronics Control). HDMI CEC allows devices connected via HDMI to control each other. If your display supports this feature, you can enable it on the Raspberry Pi and use CEC commands to turn the display on and off.
  2. Utilize Display Power Management Signaling (DPMS): DPMS is a feature of the X Window System that allows for power management control of displays. You can install and configure DPMS on your Raspberry Pi to control the display power. Here’s how you can do it:
  • Install the xset command-line tool if it’s not already installed:
sudo apt-get install x11-xserver-utils
  • Turn off the display:
xset dpms force off
  • Turn on the display:
xset dpms force on

You can create scripts or schedule these commands to run at specific times or trigger them based on specific events using cron jobs or other automation tools.
3. Use a smart plug or relay: Another option is to connect the power supply of the display to a smart plug or a relay that can be controlled by the Raspberry Pi’s GPIO pins. You can then write a script to turn the smart plug or relay on and off, effectively controlling the power supply to the display.Be cautious when working with electrical circuits and ensure you have the necessary knowledge and expertise to handle it safely.

So this would work on the gpio connected display also? I will give it a try and report back :slight_smile:

Hi Roo

I think Marty has already tried switching the display power.

Cheers Bob

Hi Marty,

Welcome to the forum :slight_smile:

Can you give us some more specifics about the display you are using? There are a whole stack of 7" displays out there and they may not work quite the same. If you can provide the part number or a link to the one you’ve got we may be able to look into how that specific display operates for you.

1 Like

The display I am using is this one. So far I have tried a few things via cmd line that have not yet worked. I still need to try the ones above later on this week.

My first attempt was to just cut the power to the display (which was initially powered from the gpio line) Then I also tried powering the screen and the pi individually and just togling the display power. Both methods had the same results where the display would not come back online when it was powered back up with out a full raspberry pi reboot.

1 Like

Hi Marty,

Thanks for that extra info, since the official display uses the Pi’s DSI interface instead of HDMI there are a few quirks to it. Unfortunately neither the DSI interface or HDMI interface of the Raspberry Pi are hot-pluggable. If something is not connected at boot it won’t be detected later, and a device that is disconnected may not always reconnect smoothly.

I’ve found this forum thread from Pimoroni which suggests you can however turn the backlight on and off for the display, which is where the majority of the power is used and if the backlight is off the display will appear off to most users. The commands to switch it are below.


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


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

Ok good :slight_smile: Thankyou very much I will try these tomorrow. Would this also prevent screen burn in by having the display backlight turned off?

Hi Marty,

Great question, I don’t think this would impact the time to burn in an image since the LCD is likely still displaying the same picture, it’s just not visible to the end user since there is no backlight behind to provide the contrast to see it.

Ah yeah. The main reason for turning off the display was to be able to increase its life time displaying fairly much the same image for most of its life.

Hi Marty,

In that case perhaps you can find an existing tool that will slightly offset your static image elements after a certain period of time. For example if you had a watermark that is always displayed, shifting it by a couple of pixels each hour means the same image isn’t always in the same place, but for the end user it’s likely to be unnoticed.