How to stream Xbox Cloud games with Raspberry Pi
With current generation consoles still hard to find even a year after their launch, game streaming services have become very popular. For a few dollars a month, we can stream a library of games to our laptops, desktops, and mobile devices.
With the recent version of the Raspberry Pi operating system, based on Debian 11 “Bullseye”, we see that the Chromium web browser now supports hardware acceleration, which means that we can finally use the game streaming services. with the Raspberry Pi 4.
In this tutorial, we will set up a fresh installation of Raspberry Pi OS Bullseye, overclock our Raspberry Pi 4 to 2 GHz and finally we will automate the process, turning our Raspberry Pi into a 1080p gaming console.
For this project you will need
- Raspberry Pi 4 4 GB
- 16 GB Micro SD card
- Keyboard, mouse and 1080p display for your Raspberry Pi
- Ethernet Internet connection
- Cooling for your Raspberry Pi 4. We used the Pimoroni Fan Shim, but passive cooling would be best.
- Xbox Game Pass Platinum
- Xbox controller
Install Raspberry Pi OS Bullseye on your Raspberry Pi 4
We start the process by installing the latest version of Raspberry Pi OS on a new micro SD card.
1. Download, install and run Raspberry Pi imager.
2. Click the Choose operating system button. A menu appears.
3. Select Raspberry Pi OS (32 bit) in the operating system menu.
4. Click Choose storage and select your card menu.
5. Click Write. This process will take several minutes as the Raspberry Pi Imager downloads the Raspberry Pi operating system and burns it to your microSD card.
6. Remove the SD card and place it in your Raspberry Pi then start on the desktop.
7. Open a terminal and update software on your Raspberry Pi.
$ sudo apt update $ sudo apt upgrade -y
Overclock your Raspberry Pi 4
To ensure you get the best performance, overclock your Raspberry Pi from 4 to 2 GHz. It’s easy to do and gives you a free performance boost. Make sure you have adequate cooling for your Raspberry Pi 4.
1. Turn off your Raspberry Pi and attach your cooling option if it’s not already there. Start.
2. Open a terminusEarth use this command to open the config.txt file.
$ sudo nano /boot/config.txt
3. Scroll down to the bottom of the file and make a new line. This will be a comment, used to identify what the underlying code will do.
#Overclock to 2 GHz
4. Use these settings to set the overclock. Press CTRL + X, then press Y and Enter to save and exit.
arm_freq=2000 gpu_freq=750 over_voltage=6 force_turbo=1
5. Restart your Raspberry Pi for the changes to take effect.
Run Xbox Cloud Gaming (Beta) on Raspberry Pi 4
This is really the easy part! The latest version of Chromium (v92) shipped with Raspberry Pi OS “Bullseye” comes with built-in hardware acceleration. This means that playing YouTube videos is much smoother than the previous one, and more importantly, our games are performing better than ever.
1. Plug your Xbox controller into a free USB port. At present, Raspberry Pi OS cannot use the controller via bluetooth.
2. Click the browser icon to open a new browser window.
3. Go to https://xbox.com and log into your account. If you are prompted to save your login information, do so because later we will automate much of this process.
4. Click on Play to start the Cloud Gaming service.
5. Using the controller, select a game and start playing.
Automatically starting Xbox Cloud Gaming on startup
Playing games should be fun, so plug in a keyboard, mouse, etc. to log in every time is a chore. What if we automated the process? In the previous section, we asked the browser to remember our login information, so now the browser is open as soon as the Raspberry Pi desktop starts up.
1. Open a terminal window and create a file called xbox.sh. This file in your home directory (/ home / pi) will store all the steps necessary to run the game service.
$ nano xbox.sh
2. Add a line that tells the system which language we use, in this case a Bash script. Add a second line to force the system to pause for five seconds before continuing.
#!/bin/bash sleep 5
3. Use xrandr to force the display to use 1080p resolution. This is an adjustment that will replace a bug in Raspberry Pi OS Bullseye that forces the default resolution to match the display. For users of 4K displays, this is an essential step.
xrandr -s 1920x1080
4. Add the last line, which is the command to run. In this case, it opens Chromium in full screen and goes straight to the xbox.com gaming site (in our case the en-GB site for the UK, but replace it with the URL for your region). The last part of the line is “&” and that tells Linux to run the command in the background.
Exec=chromium-browser --start-fullscreen https://xbox.com/en-GB/play &
5. Press CTRL + X, then press Y and Enter to save and exit.
6. Convert xbox.sh to an executable file.
chmod +x xbox.sh
7. In the terminal, create a file called xbox.desktop which will run when the desktop starts.
$ sudo nano /etc/xdg/autostart/xbox.desktop
8. Create two lines inside the file. The first is a description of the file. The second line is the command to be executed. In this case, it will call the Bash script we just wrote.
[Desktop Entry] Exec=/home/pi/xbox.sh
ten. Press CTRL + X, then press Y and Enter to save and exit.
11. Restart your Raspberry Pi for the changes to take effect.
Your Raspberry Pi 4 will now boot directly into the Xbox Cloud Gaming service, and you are ready to play!
To quit a game through the controller, tap the Xbox logo and select Quit Game.