• Published on | Jul 09, 2015 | by FozzTexx

Lighting Fireworks With a Raspberry Pi

A couple of months ago I purchased several relay boards and switching power supplies off eBay with the plan to re-use one of my original (256 megs of RAM and no mounting holes) Raspberry Pi model B computers as a sprinkler controller. The parts arrived and I set them aside expecting to have time to work on the project after the 4th of July. About two weeks before the 4th though I realized if I got the project assembled in time I could use the sprinkler controller as a fireworks controller.
Parts needed in previous years In the past I've had a rather cumbersome setup for controlling fireworks which required dragging out lots of different components. I actually haven't done computer controlled fireworks for several years because there were just too many things to drag out and hook up. With the Pi I could integrate a WiFi AP, the relays, and the computer all on a small board, which would make it much easier to setup outside.
Assembling the hardware was very simple. To control the three relay boards I used 74HC595 shift registers, one for each relay board. I also had to use a pull-up resistor wired to the 3V3 to keep the shift registers disabled until I was ready to use them. If I didn't do that then the relays would all turn on as soon as power was applied.
Power is provided by a 12V sealed lead acid (SLA) battery. I have the 12V battery go into my switch box which has two lighted switches on it, the output of one switch goes to the switching regulator to power the Pi, the other switch has one of those flip-down safety covers and goes through the relays to the fireworks.
To ignite the fireworks you need something called a squib or e-match. The ones I make use nichrome wire and a paper match. I’ve written an article on that previously, and here’s a video showing how I put them together.
After getting the hardware assembled the next thing was software. I re-used the web interface that I wrote for the laptop years ago and made a quick and dirty Python script that could run as root to control the GPIO. In order to get the script to run as root I used sudo and allowed the web server to call sudo without a password. Yah, it's a security hole but the Pi was going to be outside on the lawn with no internet access so one of my guests would have to hack it during the 15 minutes or so that the Pi would be booted up running the show.
With the web interface working and able to control the relays I needed a way to access the web interface. Instead of dragging a monitor & keyboard & mouse out, I chose to use a pocket computer that I have: an iPhone. To use the iPhone I would need to be able to connect it to the Pi wirelessly. Since the Pi would be in the backyard far away from any internet access, the Pi itself would need to act as a WiFi access point.
The only USB WiFi adapters I have are the Edimax ones. There are several tutorials out there on how to setup a Pi as an AP and get hostapd running. The stock hostapd that comes with raspbian doesn't support the Edimax, but all the tutorials either provide a custom version of hostapd, or tell you where to download it and compile it yourself. Nothing worked though. The Pi would broadcast the SSID, but whenever I tried to join the network it would always fail.
In desperation and with time running out I jumped on Amazon to see if they sold any of the other WiFi adapters that were known to work with the stock hostapd. They had the Panda Ultra with 2 day Prime shipping, so I ordered a couple. When they arrived I plugged one in and after restoring the stock hostapd it worked! Hurray!
For whatever reason though, only two of the eight things I wired up worked. As I activated each I could see the nichrome wire glow red hot but for some reason the match or the fuse didn't light. I think for next time I will put some resistors on the 12V power to limit the current to the nichrome so it will stay red-hot without vaporizing.
Main parts:
  • Raspberry Pi model B
  • AC/DC 9-48V To 1.8-25V 3A Switching power supplies (eBay link)
  • 5V 8 channel relay modules (eBay link)
  • 74HC595 shift registers
  • Detonator - Simple GPIO relay software (github link)

Join The Discussion

+1  Posted by MArk B. • Jul.09.2015 at 17.53 • Reply

Me likes. I was going to do pretty much the same thing two years ago after I got hit in the face one inch from my eye by a rock kicked up by some fireworks. Biggest reason I didn't finish it was the difficulties figuring out what to do for the squibs.

Now to time it with music a lasers.

+1  Posted by ronan • Jul.04.2016 at 17.23 • Reply

It looks like you are only controlling one device per relay, by controlling VCC. You could control many more devices ( (x/2)2 ) if you used one relay to control VCC and another to control the path-to-ground. For each VCC relay, put 8 devices on a shared VCC leg, but each one independently switched to ground by one of the relays from the other bank. This way, 16 relays can independently fire 64 pyrotechnics.

+1  Posted by FozzTexx • Jul.04.2016 at 18.40 • Reply

I've setup a matrix with diodes in the past to control the fireworks. For this first time though I wanted to keep it simple and wired up just a few fireworks. Wiring up a lot of things to a matrix is complex and time consuming. I did make a few small boards with screw terminals and a larger board with all the diodes on it. Once I get things reliable I might try the diode matrix again.

+1  Posted by Jenson • Nov.02.2016 at 17.12 • Reply


Please could you help me get the software running on my Raspberry Pi 3??


+1  Posted by FozzTexx • Nov.02.2016 at 17.15 • Reply

You just need Python and you can run the fireworks.py script.

+1  Posted by Jenson • Nov.02.2016 at 17.16 • Reply

What about the web interface??

+1  Posted by FozzTexx • Nov.02.2016 at 17.18 • Reply

cd to src and type make

+1  Posted by Jenson • Nov.02.2016 at 17.22 • Reply

It failed and said: cl_main.m:21:32: fatal error: ClearLake/ClearLake.h: No such file or directory

import <ClearLake/ClearLake.h>

+1  Posted by FozzTexx • Nov.02.2016 at 17.24 • Reply

You need to install the ClearLake library and Makefiles:



+1  Posted by Jenson • Nov.02.2016 at 17.28 • Reply

Its saying this This program built for arm-unknown-linux-gnueabihf and i can't work out what to do?

+1  Posted by Jenson • Nov.02.2016 at 17.24 • Reply

Is there any other easier way I can contact you other than the website?

+1  Posted by FozzTexx • Nov.02.2016 at 17.30 • Reply

+1  Posted by Jenson • Nov.02.2016 at 17.30 • Reply

Ok Its saying this This program built for arm-unknown-linux-gnueabihf and i can't work out what to do?

+1  Posted by Alex • Dec.04.2016 at 11.31 • Reply

Would it be possable to set off squibs using your method. I work in the film industry and it would be cool if I could set body hits off from my phone

+1  Posted by Ariba • Sep.29.2019 at 19.48 • Reply

Not a bad project, but i think the response time is too long between clicking the channel and ignition. Guess using the webinterface there is no way making it faster.