How to Disable Screen Sleep in Raspberry Pi

raspberry pi prevent screen from turning off

The Raspberry Pi is a wonderfully versatile computer, perfect for everything from a desktop replacement to a dedicated project hub. If you’re using it to power a digital dashboard, a retail kiosk, a home automation panel, or even a simple weather display, you need the screen to stay on.

However, you’ve likely noticed that after a few minutes of inactivity, the screen goes black. This is due to a built-in power-saving feature called Screen Blanking. It’s managed by the X Window System’s screensaver extension and is designed to conserve power and prevent screen burn-in on older CRT monitors.

While well-intentioned, this feature can be a real roadblock for any project that requires a persistent display. Fortunately, disabling it is simple.

In this comprehensive guide, we’ll explore several methods to prevent your Raspberry Pi’s screen from sleeping, whether you prefer using the graphical desktop or the command line.

Method 1: The Easiest Way (Using the Desktop Interface)

For anyone running the standard Raspberry Pi OS with a desktop, this is the most direct and user-friendly method.

  1. Click the Raspberry Pi icon in the top-left corner to open the main menu.
  2. Go to Preferences > Raspberry Pi Configuration.
  3. In the configuration window that opens, navigate to the Display tab.
  4. You will see an option for Screen Blanking. By default, it’s set to ‘Enable’. Simply click the ‘Disable’ radio button.
  5. Click OK. You’ll be prompted to reboot your Raspberry Pi for the change to take effect. Click Yes.

Once your Pi restarts, the screen will no longer go blank due to inactivity.

Method 2: For Terminal Fans (Using raspi-config)

If you are working “headless” via SSH or just prefer the command line, the raspi-config utility is your best friend. It’s a powerful, menu-based tool for managing your Pi’s settings.

  1. Open the Terminal or connect via SSH.
  2. Launch the configuration tool with this command:
sudo raspi-config
  1. Use the arrow keys to navigate down to Display Options and press Enter.
  2. Select Screen Blanking from the next menu and press Enter.
  3. The system will ask, “Would you like to enable screen blanking?”. Select No and press Enter.
  4. You’ll get a confirmation that screen blanking has been disabled. Press Enter to continue.
  5. Navigate to <Finish> on the main menu and press Enter. When asked to reboot, select <Yes>.

This accomplishes the exact same thing as the desktop method, but entirely through the terminal.

Method 3: The Advanced Way (Using xset for Temporary Control)

Sometimes, you may not want to disable screen blanking permanently. Perhaps you only need the screen to stay on while a specific long-running script is active. For this, the xset command is perfect. It allows you to modify X Window System preferences for the current session.

Open a Terminal window on the desktop and run the following commands:

# Disable the screensaver from starting
xset s off

# Disable Display Power Management Signaling (DPMS)
xset -dpms

# Prevent the screen from going blank
xset s noblank

These settings are temporary and will be reset the next time you reboot.

To make these xset changes permanent without using raspi-config, you can add them to your session’s autostart file. This is a great solution if you want to avoid a system-wide configuration change.

Simply run this command in the terminal to append the settings to the autostart script:

echo "@xset s off -dpms s noblank" >> ~/.config/lxsession/LXDE-pi/autostart

This change will take effect on your next login or reboot.

A Crucial Tip for Raspberry Pi OS Lite Users

The methods above are for the desktop version of Raspberry Pi OS. If you are using the Lite version (which has no graphical interface), screen blanking is controlled by the Linux kernel’s console.

To disable it on Raspberry Pi OS Lite, you need to edit the kernel command line:

  • Open the cmdline.txt file using a text editor like nano:
sudo nano /boot/cmdline.txt
  • This file contains a single, long line of text. Go to the end of the line, add a space, and then append the following parameter:
consoleblank=0
  • Press Ctrl+X, then Y, then Enter to save the file and exit.
  • Reboot your Pi for the change to take effect:
sudo reboot

Now, your command-line console will remain active and visible.

Troubleshooting Common Problems

  • “My screen still turns off!”: If you’ve disabled screen blanking on the Pi but the monitor itself is still going to sleep, check the monitor’s internal settings. Most modern displays have their own power-saving or “eco” modes that will turn off the display when no signal change is detected.
  • “I want a longer delay, not to disable it completely.”: If you just want more time before the screen blanks, you can use xset to define a timeout. For example, to set a 30-minute (1800 seconds) timeout, you would use: xset s 1800.

I hope this detailed guide provides you with the perfect solution for your project. By taking control of this simple setting, you can ensure your Raspberry Pi display serves its purpose without interruption.

What exciting project are you building that requires an always-on display? I’d love to hear about it in the comments below. Happy building

Posted by Devender Gupta