I love my Sharks, but don’t always feel like going to the game. Watching from home is great, no traffic, comfy couch, good view, cheap food, no line for the bathroom. On the other hand, there’s nothing like being at the game. So being able to bring some of the sights and sounds to my living room would be awesome. I recalled the old Budweiser commercials for a Goal Light, but it’s $175 price tag along with many lackluster reviews for it made me wonder if I could do better myself. I already had several Raspberry Pi’s (henceforth rpi) sitting around, LED string lights, and jumper wires from previous projects, so I decided to take a crack at creating my own NHL goal light and horn.
What it currently does:
- Plays team’s intro tune when the game is scheduled to start
- Plays team’s goal horn and lights up LED lights when team scores
- Plays team’s power play tune when team goes on the power play
- Plays team’s victory tune when team wins
How it works:
The NHL is awesome and has an undocumented REST API that publishes up to the second live game information (https://statsapi.web.nhl.com/api/v1/schedule?teamId=28). Querying this API we can determine when goals are scored, when the game starts, when there is a power play, etc.
- Raspberry Pi: any model will be up to snuff for this project. There is little difference in price with the latest and greatest. You will want to get a case and power supply as well. Be sure the case has easy access to the rpi’s GPIO pins.
I used: Raspberry Pi 2 B+
Recommended: CanaKit Raspberry Pi 3 B+ with Clear Case and 2.5A Power Supply
- MicroSD Card: go with at least 8GB
- LED Strip Lights: there are several popular types, if you go with anything other than WS2811 or WS2812 you may have to modify the code and find appropriate Python packages.
I used: WS2811 LED Strip Light
- LED Strip Light Power Supply: the lights didn’t come with their own power supply, so I used a WS2811 bluetooth controller I had from a previous project which also supplies power. The bluetooth is unnecessary, any power supply will do.
I used: WS2811 LED Bluetooth Controller
- One 330 ohm resistor and five jumper wires: these connect the power, ground and data lines between the rpi’s GPIO pins, the LED light strip and the power supply.
I used: ELEGOO Electronics Kit
- Speaker: any will do, it needs to connect to the rpi’s aux audio port.
I used: an older model of OontZ Angle 3 PLUS
- Soldering iron: only one thing to solder, so you might be able to get away without one.
- Step 1: Setup microSD card with Raspbian
- Download Raspbian Stretch Lite image from https://www.raspberrypi.org/downloads/raspbian/
- Using Etcher write image to micro SD card
- Step 2: Setup rpi
- Change default password
- Get updates
- sudo apt-get update
- sudo apt-get upgrade
- Step 3: Setup remote access
- Enable SSH
- sudo raspi-config
- Select “5 Interfacing Options”
- Select “P2 SSH”
- When prompted “Would you like the SSH server to be enabled?”, select “Yes”
- Setup SSH keys for passwordless access
- cd ~/.ssh
- ssh-keygen rsa-2048
- cp id_rsa.pub authorized_keys
- chmod 400 authorized_keys
- Move id_rsa to system you intend to access rpi from
- Step 4: Install pip and Python packages
- sudo apt-get install python3-pip omxplayer
- sudo pip3 install rpi_ws281x adafruit-circuitpython-neopixel subprocess python3-gpiozero
- Step 5: Download code
- cd ~/nhlgoallight
- sudo git clone https://github.com/tcaserza/nhlgoallight.git
- Step 6: Connect LED lights
- Get rpi GPIO information
- Solder 330 ohm resistor on jumper wire you intend to use for data
- Connect LED light ground to LED Controller ground
- Connect rpi ground to LED Controller ground
- Connect LED light power to LED Controller power
- Connect jumper wire with ohm resistor from GPIO 21 to LED light data (green) with resistor on LED light end
- I chose to use GPIO 21 instead of 18 because of possible conflict with audio
- Test LED lights
- sudo python rpi_ws281x/python/examples/SK6812_strandtest.py
- Step 7: Connect speaker
- Connect to rpi aux audio port
- Test speaker
- omxplayer nhlgoallight/audio/goal_horn_1.mp3
- Step 8: Tinker
- The default team is the San Jose Sharks. If you happen to root for someone else, you are a horrible person, and you will want download your teams goal horn, intro tune, power play tune, victory tune, etc. and put them in the audio folder and name them goal_horn_1.mp3, intro.mp3 power_play.mp3, victory.mp3 respectively.
- Additionally, if you don’t bleed teal, you will likely want to change the light color by editing the run_goal_light() function in led.py.
- Test it out
- sudo python test.py
- Step 9: Run it
- sudo python nhlgoallight.py
- Note that the script will run forever, it checks every morning to see if there is a game that day, and if there is, it waits until game time and starts running, otherwise it sleeps until the next morning.
- Step 10: Keep it running as a service
- When you have everything tuned to your liking, you will want to run it as a service in case it stops for any reason.
- sudo cp ~/nhlgoallight/nhlgoallight.service /etc/systemd/system
- sudo systemctl enable myscript.service
NHL Goal Light and Horn in action:
Sharks score, NHL API gets updated within a couple of seconds, script polls and sees the goal, then…
Several versions of an NHL goal light on Raspberry Pi’s and Arduinos already exist, so I can’t take any credit for this being an entirely original idea. However, I have not seen any versions using LED lights as well scanning for and playing tunes for the intro, power play, victory, and puck drop.
This site was a huge help in understanding how to get the WS2812 LED lights set up.
This site documents a good amount of the undocumented NHL API required for this project to even be a thing.