Like most Canadians, I watch a little bit of hockey, and I’ve recently been looking for a way to express my joy automatically when my team scores a goal. With an old truck horn, an air solenoid, a compressor, and a Raspberry Pi (a Raspberry Pi Zero W will work), we can create an automatic air horn that goes off every time your team scores a goal to let everyone in your house (and your neighbors) know.
What You’ll Need For This Project
- Raspberry Pi with Internet connectivity (If you use a Zero W, make sure to solder the pins)
- 12 volt (normally closed) air solenoid (opens in new tab)
- 12 volt power supply (opens in new tab)
- A relay module compatible with the Raspberry Pi (opens in new tab)
- At least 3 jumper cables
- A few feet of extra wiring suitable for a 12v circuit
- Air compressor and hose (or another source of compressed air)
- A pneumatic horn (from a truck, train, or something else) (opens in new tab)
- A male push-to-connect pneumatic fitting (opens in new tab) (depending on your air horn)
- 1 male quick-connect pneumatic adapter (opens in new tab)
- A roll of PTFE tape (opens in new tab)
- A tool box with standard tools
- Polyethylene tubing (opens in new tab) (depending on your air horn)
How To Build a Raspberry Pi NHL Air Horn
1. Set up your Raspberry Pi. If you don’t know how to do this, check out our story on how to set up your Raspberry Pi for the first time or how to set up a headless Raspberry Pi (without monitor or keyboard).
2. Install git as necessary, and clone the repository to your Raspberry Pi.
cd ~/ sudo apt-get update && sudo apt-get -y install git git clone https://github.com/rydercalmdown/raspberry_pi_goal_horn.git
3. Descend into the cloned repository and run the installation command to install all lower-level and python-based requirements for the project to work.
cd ~/raspberry_pi_goal_horn make install
4. Connect your air horn to your solenoid using whatever works best for your specific type of air horn. Since I found mine at a junkyard, I’m using a combination of polyethylene tubing and push-to-connect fittings to bridge the gap between the solenoid and the horn. Make sure whatever you’re using is pressure-rated.
5. Attach a male quick-connect fitting to the input end of your 12 volt solenoid, making sure to use PTFE tape to prevent any leaks.
6. Wire one end of your solenoid to a 12 volt power source. This will provide power to the solenoid allowing it to open.
7. Wire the other end of your solenoid to the normally-open port of your relay module. This ensures that when the power is off to your relay module, the solenoid doesn’t open and the horn doesn’t fire.
8. Wire the common port of your relay module to your 12 volt power supply’s ground. This completes the circuit, with the solenoid acting as the load, and the relay acting as the switch.
9. Connect the VCC and ground pins of your relay board to your Raspberry Pi, using board pins 4 (VCC) and 6 (ground) respectively.
10. Connect the data pin on the relay from the channel you wired the solenoid to Raspberry Pi BCM pin 22 (board pin 15). This allows our pi to communicate with the relay, closing and opening the circuit.
11. Connect your air compressor to the quick-connect input on your solenoid. Adjust the pressure on your compressor’s regulator as necessary - mine is set to around 50 PSI for my truck horn.
12. Set your desired team’s abbreviation in src/app.py, this will ensure only changes to your team’s score trigger the horn.
from score_manager import ScoreManager if __name__ == '__main__': print('Starting system...') sm = ScoreManager('TML') # Change to whatever your team’s abbreviation is (example: MTL) sm.run()
13. Run the application to test the setup. When starting, the system will trigger the solenoid to activate the horn briefly before it starts making requests to get your team’s score. To exit, use Ctrl + C.
14. Run the application during a game.
If there are no listed live games for your team, the system will check every 30 seconds until there is. During a game, it will check every 30 seconds to see if your team has scored a goal. If the score has changed since the last time, cover your ears and celebrate.