Step 0: Raspberry Pi Imager
- Choose your Raspberry Pi
- Select Raspberry Pi OS (Other) - OS Lite (64bit)
- Set hostname (I put matrix), set pass (I kept user as pi), setup wifi/locale
- Enable ssh using password
- When done, insert microSD card in pi and wait a few min for boot up
Step 1: Login via ssh
- ssh [email protected]
- This puts you in the /home/pi directory
- Use pwd to confirm where you are throughout this process
Step 2: Update packages and install git
- sudo apt update (get latest packages)
- sudo apt upgrade (upgrade out of date packages)
- sudo apt install git
- sudo apt install vim (optional, else replace vi with nano)
Step 3: Clone and enter the repo
- git clone --recurse-submodules https://github.com/kylejohnsonkj/rpi-spotify-matrix-display
- recurse-submodules additionally pulls the rpi-rgb-led-matrix library which we will install as a python module later
- cd rpi-spotify-matrix-display/
Step 4: Update config.ini with Spotify credentials
- vi config.ini
- Adjust hardware_mapping and other options if necessary
- For vim: edit by tapping “i”, tap esc then :wq enter to save
Step 5: Setup python virtual environment
- python3 -m venv .venv
- source .venv/bin/activate
- You should now see (.venv) before your shell prompt
- use “which python3” to confirm path
- /home/pi/rpi-spotify-matrix-display/.venv/bin/python3
Step 6: Install requirements using venv python3
- sudo .venv/bin/python3 -m pip install -r requirements.txt
- Must sudo .venv/bin/python3 as matrix will run as root
- https://stackoverflow.com/a/66410467/12821693
Step 7: Install rgbmatrix python module (follow exactly!)
- sudo apt install python3-dev cython3
- cd rpi-rgb-led-matrix
- make -C bindings/python/rgbmatrix -B CYTHON=cython3
- make
- cd ../impl
- sudo ../.venv/bin/python3 -m pip install ../rpi-rgb-led-matrix/bindings/python --use-pep517
Step 8: Disable sound card and isolate cpus
- sudo vi /etc/modprobe.d/alsa-blacklist.conf, add “blacklist snd_bcm2835”
- sudo vi /boot/firmware/config.txt, set “dtparam=audio=off”
- sudo vi /boot/firmware/cmdline.txt, add “isolcpus=3"
- sudo reboot
- ssh back in once rebooted
Step 9: Run the controller
- cd rpi-spotify-matrix-display/
- source .venv/bin/activate
- cd impl
- sudo ../.venv/bin/python3 controller_v3.py
- Go to the following URL
- Paste the redirected url
- Play some music and the display should appear!
Step 10: Setting up autostart at login
- sudo vi /etc/systemd/system/matrix.service
[Unit]
Description=rpi-spotify-matrix-display
[Service]
WorkingDirectory=/home/pi/rpi-spotify-matrix-display/impl
ExecStart=/home/pi/rpi-spotify-matrix-display/.venv/bin/python3 /home/pi/rpi-spotify-matrix-display/impl/controller_v3.py
[Install]
WantedBy=default.target
- sudo systemctl start matrix
- sudo systemctl enable matrix (enables autostart)
Step 11: Add aliases for fun
- cd /home/pi
- vi .bash_aliases, add alias matrix='sudo service matrix’, :wq
- source .bash_aliases
- Now you can type matrix start, matrix stop, matrix restart!