Categories
raspberrypi technology virtualreality

Control your Raspberry Pi 5 from your Meta Quest 3 over Bluetooth

The Meta Quest 3 is capable of so much since it is an Android based device and can leverage the existing Android app ecosystem – if you know how to do it! Let’s control our Raspberry Pi 5 from within virtual reality over Bluetooth.

Keep in mind that using Bluetooth to pair these two devices limits our ability to connect from a physically distant location. I personally prefer this since exposing it over say, SSH, would open it up to potential exploits over the Internet. I personally wouldn’t trust an SSH private key to an Android app – if you see one asking you for that, I would recommend against using it. For my use case, Bluetooth works perfectly well since I always use my Pi when I’m in close proximity to my Quest.

Disclaimer:

In this tutorial I endorse the use of Bluedot, an Android app by the tech rockstar Martin O’Hanlon. The app is MIT licensed which means you are free to use it for private or commercial use, and you can even distribute it, but you don’t have any warranty or liability claims when using it.

Prerequisites:

  • Follow this video tutorial or this pdf tutorial and have SideQuest downloaded, installed and connected to your Quest 3. Note that you will need the “advanced” version of SideQuest in order to install apk files not distributed by the SideQuest store.
  • You will need to download the apk file from the Bluedot Github repository – click here for the direct download link, or here for the repository link
  • You should be familiar with how to sideload an apk file (not from the SideQuest store). See page 7 of the pdf tutorial for a refresher
  • Raspberry Pi 5 with appropriate accessories
    • an SD card with the Raspberry Pi OS and enough space for this exercise – 50 GB or more should be plenty
    • a power supply that outputs 27W that connects via USB-C
    • a micro HDMI cable with an output compatible with a monitor of your choice
    • a mouse and keyboard that can connect via USB type A (the standard big type) or Bluetooth

If you are brand new to the Raspberry Pi, there is a great “Getting Started” tutorial at https://www.raspberrypi.com/documentation/computers/getting-started.html . This tutorial assumes you have already gone through these steps and have your Pi powered, booted up, configured with your login details, and connected to Wifi .

Steps:

  1. Sideload the Bluedot apk onto the Meta Quest 3

2. Boot up your Pi and ensure that Bluetooth is enabled – on mine it came up enabled automatically.

3. Create a Python script on your Pi to listen for Bluedot button presses. Here is a simple one from the Bluedot docs that says “Hello World” when the button is pressed

from bluedot import BlueDot
from signal import pause

def say_hello():
    print("Hello World")

bd = BlueDot()
bd.when_pressed = say_hello

pause()

4. Install the dependencies bluedot and signal, using a virtual environment as described in this tutorial. Keep in mind that using pip to install packages in the Pi environment directly may break system packages.

5. Run the Python script on the Pi. Unless this script is active and running Bluedot on the Pi will not be able to pair with the Bluedot app on the Quest 3

(myenv)pi@raspberrypi:~ $ python3 myrecipe.py

6. Back on the Quest, turn on Settings > Bluetooth. It should automatically begin scanning for available devices

7. On the Pi, click the Bluetooth icon and click “Make Discoverable”.

The icon should begin flashing

8. On the Quest you should see “raspberrypi” as an available device. When you click it, it will give you a pairing code. Back on the Pi, click the pop-up for pairing. On the Quest, click “Pair” as well. I found it easier to click the pairing pop-up on the Pi first and then on the Quest. If you happen to do it in the reverse order clicking “Pair” on the Quest first, you will need to click “Stop Discovery” on the Pi to get it to recognize the pairing.

The Quest and Pi should be paired via Bluetooth at this point.

9. Open the Bluedot app from App Library > Unknown Sources

10. Select the raspberrypi from the list of devices.

It should pop up with a screen that says “Connected” and a big blue dot

11. Click the dot, and check the Pi to see if it says “Hello World”

12. If it does, congratulations, you have connected your Quest 3 to your Pi 5!

In this tutorial we learned how to connect a Raspberry Pi 5 to a Quest 3 over Bluetooth, and click a button to execute an action on the Pi from with virtual reality.

Enjoy!

Categories
raspberrypi technology virtualreality

Adventures with Immersed VR on the Pi 5

Raspberry Pis are cool. Virtual Reality, also cool.

Let’s make a Raspberry Pi Virtual Reality coolness sandwich!

To be clear, this tutorial is about getting an Immersed VR virtual monitor working with the Pi 5. It is NOT about running a VR simulator with the Pi 5 – if you want that you can get some guides with a Google search on “DIY VR on raspberry pi.”

Disclaimer:

This tutorial makes use of a prototype build compatible with the Raspberry Pi which the Immersed VR team made available to me through Discord. It is not yet available on their downloads page and may not be compatible with all headset/raspberry pi combinations. YMMV.

Shout-Out:
This tutorial would not have been possible without the inspiring work done by Augusto Ícaro . Check out https://github.com/augustoicaro/Immersed-Linux-Virtual-Monitors and be prepared to go ooooh-ahhhhh 🙂

Prerequisites:

  • An Immersed VR account – their free starter mode should work, although you can also earn Pro by using Immersed in starter mode minimum 3 out of 7 days. More on that at https://immersed.com/faq#how_to_unlock_pro_mode
  • Access to the Immersed VR Discord – invite available at https://discord.com/invite/zy6KMbJ – in order to request and download the prototype build. Check out the #linux-help channel for the download and any assistance you might need
  • Headset compatible with Immersed VR – you can see their compatibility statement at https://immersed.com/faq under the “Compatibility” heading
  • Raspberry Pi 5 with appropriate accessories
    • an SD card with the Raspberry Pi OS and enough space for this exercise – 50 GB or more should be plenty
    • a power supply that outputs 27W that connects via USB-C
    • a micro HDMI cable with an output compatible with a monitor of your choice
    • a mouse and keyboard that can connect via USB type A (the standard big type) or Bluetooth
  • Wifi connectivity – Immersed VR works over your wifi network. Both the Pi and the headset should be connected to the same wifi network.
    ** Note that it is advisable to use a private wifi network rather than a public one, since public ones are vulnerable to hacking and could result in your session being compromised

If you are brand new to the Raspberry Pi, there is a great “Getting Started” tutorial at https://www.raspberrypi.com/documentation/computers/getting-started.html . This tutorial assumes you have already gone through these steps and have your Pi powered, booted up, configured with your login details, and connected to Wifi .

All the following steps should be executed on the Pi itself, except for the scp command which would be from a separate computer.

Steps:

  1. Download the app image from the Discord #linux-help Immersed VR channel to your Pi. If you don’t want to install Discord on your Pi, you can also download it on a separate computer that has Discord and use secure copy (scp) to transfer it to the Pi
    To use this second method, first copy your main computer’s public ssh key to the Pi as ~/.ssh/authorized_keys. A sample scp command to do this would be:
scp -i mylaptop_private_ssh_key /Users/mylaptopuser/Downloads/Immersed-aarch64.AppImage mypiuser@192.168.1.165:/home/mypiuser/Downloads

2. Once the App Image is on the Pi, grab the Linux setup script

wget https://raw.githubusercontent.com/augustoicaro/Immersed-Linux-Virtual-Monitors/main/scripts/immersed-setup/immersed-setup.sh

3. This script assumes your app image is in /home/mypiuser/Applications. Either create that directory and move both the setup script and the app image into that directory, or modify the setup script to find these resources wherever you want them to live.

4. Modify the setup script to use the App Image you downloaded. I had to replace “x86_” with “aarch”. A sample command to do this is:

sed -i -e 's/x86_/aarch/g' ~/Applications/immersed-setup.sh

5. Make the setup script executable

chmod a+x ~/Applications/immersed-setup.sh

6. Put your Applications directory on your PATH by adding this export line to your .bashrc file and then sourcing it to load it in your terminal.

echo -n "export PATH=$PATH:$HOME/Applications" >> ~/.bashrc
source ~/.bashrc

7. Install additional packages and make a symbolic link for libwlroots. Note that these versions are specific to the 10.3.2 version of the App Image and may change when this is updated.

sudo apt install -y libfuse2 libwebkit2gtk-4.0 libva2 libva-drm2
sudo ln -s /usr/lib/aarch64-linux-gnu/libwlroots.so.11 /usr/lib/aarch64-linux-gnu/libwlroots.so.5

8. Adjust the ~/.ImmersedConf file to setup your v4l2 camera device (to enable the virtual webcam feature). Use the Text Editor to find the line that starts with “CameraDevice” and adjust it to read like so:

CameraDevice=/dev/video7

8. Run the immersed-setup.sh script from the Applications directory.

cd ~/Applications
./immersed-setup.sh


This script may end with an error similar to this:

modprobe fatal module card_label=Immersed not found in directory /lib/modules/6.6.31+rpt-rpi-2712

If so not to worry, it means the v4l2loopback module hasn’t loaded into your current session. The v4l2loopback module relates to the webcam functionality.

To load the module, restart your Pi with shutdown now -r or by hitting the power button, letting it power off, and hitting the power button again.

9. At this point you should be able to run the setup script and not get any errors. Now it’s time to run the app image!

cd ~/Applications
./Immersed-aarch64.AppImage

Depending on what happened with the v4l2loopback module, the app image may generate a pop-up prompting you to install a few more dependencies. If so not to worry, we already installed these in step 7, so you can click “Do not display again” on these.

At this point you should be able to sign in with your Immersed VR account and pair the VR app with the Pi. The pop-up should say “Agent Ready” when it is available for the VR app.

10. In the VR app, select “Computers” and click the “raspberry pi” option. It should connect after a few moments. If it does not connect right away, try stopping the AppImage with Ctrl + C and re-run it.

11. View your fancy new monitor in VR!

OCULUS_ATTRIBUTION_ID:9279578942068913–

Congratulations! You now have the ability to connect to your Raspberry Pi 5 in virtual reality!

If you have any questions or get stuck, feel free to ping in the #linux-help channel of the Immersed VR Discord and we’ll see what we can do!