Skip to content

Instantly share code, notes, and snippets.

@kylejohnsonkj
Created November 2, 2024 17:18
Show Gist options
  • Save kylejohnsonkj/4c1fba7980409fd04865b8679b942d3a to your computer and use it in GitHub Desktop.
Save kylejohnsonkj/4c1fba7980409fd04865b8679b942d3a to your computer and use it in GitHub Desktop.
rpi-spotify-matrix-display - full pi setup

rpi-spotify-matrix-display - full pi setup

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

Step 4: Update config.ini with Spotify credentials

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

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!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment