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.
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.