Display live NHL game scores, start times, etc. on a LED matrix driven by a Raspberry Pi. Makes use of the new, still unofficial, NHL API for all game information.
Check out the accompanying blog post from the initial release of this project for some background info and more examples.
Hardware requirements and installation instructions are below.
Implement additional transitions.DONE!- Revise brightness logic to allow for more user control.
- Allow user to specify alternative team logos.
- Allow user to specify favorite team(s) and display a "next game" screen should they not be playing today.
- Better document different user options and provide examples.
- Generalize as much as possible to make easily extendable for other sports.
- A Raspberry Pi. Zero 2W and all Pi 3/4/5 models should work.
- An Adafruit RGB Matrix Bonnet (reccomended) or RGB Matrix HAT + RTC.
- HUB75 type 32x64 RGB LED matrix. These can be found at electronics hobby shops (or shipped from China for a lot cheaper). I reccomend heading to a shop to purchase if you're unsure of exactly what you need.
- An appropriate power suppy. A 5V 4A power supply should suffice, but I offer the same advice as the LED matrix. I'm currently using a 5V 8A power supply as that's what I had lying around.
- OPTIONAL: A soldering iron, solder, and a short wire.
These instructitons assume some basic knowledge of electronics, Unix, and command line navigation. For additional details on driving the RGB matrix, check out hzeller's repo (it's the submodule used in this project).
-
OPTIONAL, but reccomended: Solder a jumper wire between GPIO4 and GPIO18 on the Bonnet or Hat board. This will allow you to get the best image quality later in the setup.
-
On your personal computer, use the Raspberry Pi Imager to flash an SD card with Rasberry Pi OS Lite. During this process, be sure to...
- Set a password (keep username as "pi").
- Set your time zone.
- Specify WiFi credentials.
- Enable SSH via password autentication.
- See full Raspberry Pi Imager getting started guide here.
-
Remove the SD card from your personal computer and insert it into your Raspberry Pi.
-
Assemble all hardware per these instructions (steps 1 - 5).
-
Plug in your Raspberry Pi. From your personal computer, SSH into it and enter the password you set earlier when prompted. Assuming a username of "pi" and a device name of raspberrypi, the command would look like this:
-
Once you've SSH'd into your Raspberry Pi... If you completed step 0, disable on-board sound to take advantage of the increased image quality. If you didn't complete step 0, skip this step.
sudo nano /etc/modprobe.d/alsa-blacklist.conf
Add the following:
blacklist snd_bcm2835
Save and exit. Then enter the following:
sudo nano /boot/firmware/config.txt
Edit the "dtparam=audio" line to match the following:
dtparam=audio=off
Save and exit.
-
Disable sleep.
sudo nano /etc/rc.local
Above the line that says "exit 0" insert the following:
/sbin/iw wlan0 set power_save off
Save and exit.
-
Reboot your RPi.
sudo reboot
Wait a few minutes, then SSH into your RPi once again.
-
Update built-in software.
sudo apt-get update -y sudo apt-get upgrade -y
-
Install git and python-dev.
sudo apt-get install git python3-dev -y
-
Clone this repository, including all submodules.
git clone --recursive https://github.com/gidger/rpi-led-nhl-scoreboard.git
-
Make Python virtual environment and activate. First enter the directory we just cloned.
cd rpi-led-nhl-scoreboard/
Then, create and activate a virtual environment with the name "venv".
python -m venv venv source venv/bin/activate
-
Install required Python packages.
pip install -r requirements.txt
-
Install the LED matrix Python package. First, navagate to the LED matrix library directory.
cd submodules/rpi-rgb-led-matrix
Then enter the following:
make build-python PYTHON=$(which python) sudo make install-python PYTHON=$(which python)
-
Return to the root of your clone of this repository.
cd /home/pi/rpi-led-nhl-scoreboard/
-
If you're using a Raspberry Pi Zero 2W, 3B, or older, you'll need to update gpio_slowdown in config.yaml to prevent flickering. Reduce value by 1 each test. You can experiment and see what looks best for your hardware.
-
If you did NOT completed step 0, you'll need to update hardware_mapping in config.yaml to match the following:
hardware_mapping: 'adafruit-hat'
-
Make the scoreboard script run at startup.
nano ~/start-scoreboard.sh
Paste the following:
#!/bin/bash cd /home/pi/rpi-led-nhl-scoreboard source venv/bin/activate n=0 until [ $n -ge 10 ] do sudo /home/pi/rpi-led-nhl-scoreboard/venv/bin/python rpi_led_nhl_scoreboard.py && break n=$[$n+1] sleep 10 done
Save and exit.
OPTIONAL: You can make this repository automatically stay up to date by using this edited version of the above start-scoreboard.sh. This will check for updates on reboot before running the Python script. Generally, I would not advise doing this, but it may be useful when making this project as a gift for a non tech savvy person. It's allowed me to issue hotfixes after API changes with no action on the owner's part.
#!/bin/bash cd /home/pi/rpi-led-nhl-scoreboard source venv/bin/activate while ! ping -c 1 -W 1 github.com; do echo "Waiting for GitHub..." sleep 1 done git pull origin main pip install -r requirements.txt n=0 until [ $n -ge 10 ] do sudo /home/pi/rpi-led-nhl-scoreboard/venv/bin/python rpi_led_nhl_scoreboard.py && break n=$[$n+1] sleep 10 done
-
Now, let's make that script executable:
chmod +x ~/start-scoreboard.sh
-
And make it run at boot:
sudo ~/crontab -e
Copy the following to the bottom:
@reboot /home/pi/start-scoreboard.sh > /home/pi/cron.log 2>&1
Save and exit.
-
Finally, test your change by rebooting your Raspbery Pi. If everything was done correctly, the scoreboard should start automatically running shortly after boot.
sudo reboot
-
Grab a drink and stare at your new scoreboard for way too long.