Localizing Fireworks Launches With A Raspberry Pi

If you have multiple microphones in known locations, and can determine the time a sound arrives at each one, you can actually determine the location that sound is coming from. This technique is referred to as sound localization via time difference of arrival. [Kim Hendrikse] decided to put the technique to good use to track down the location of illicit fireworks launches.

The build is based on the Raspberry Pi, with [Kim] developing an “autonomous recording unit” complete with GPS module for determining their location and keeping everything time synchronized. By deploying a number of these units, spread out over some distance, it’s possible to localize loud sounds based on the time stamps they show up in the recording on each unit.

Early testing took place with an air horn and four recording units. [Kim] found that the technique works best for sounds made within the polygon.  Determining the location was achieved with a sound investigation tool called Raven Lite, developed by Cornell University. The process is very manual, involving hunting for peaks in sound files, but we’d love to see a version that automated comparing sound peaks across many disparate recording units. In any case, it worked incredibly well for [Kim] in practice. Later testing with friends and a network of six recorders spread over Limburg, Netherlands, [Kim] was later able to localize fireworks launches with an accuracy down to a few meters.

Similar techniques are used to locate gunshots, and can work well with pretty much any loud noise that’s heard over a great distance. If you’ve been using your hacker skills to do similar investigative work, don’t hesitate to let us know on the tipsline!

104 thoughts on “Localizing Fireworks Launches With A Raspberry Pi

    1. At least over here, we still can let off fireworks. Still trying to stave off ‘big brother’ who thinks he knows better than you…. Restricted to certain days now … grrrr. Had a Kalifornia retired teacher come to town. Complained over the the 4th…. Caused the city to shorten the number of days allowed. Of course we understand she left the city for some reason… but ordinance still in place…. In my day we could still buy decent fire crackers and M80s, bottle rockets, etc.. … Your responsibility if your dumb enough to split your fingers open when holding a cracker to long… Now the wimpy fire crackers just go ‘pop’ instead of ‘bang’ :rolleyes: .

      Neat project … but then there is always someone to use the technology (or abuse it) to take the fun out of an activity…. then control it, and finally exterminate it.

      1. I have no concerns about allowing people to blow their fingers off through their own stupidity, but I do take issue with them affecting me or my animals ‘ wellbeing while doing it. Restricted use of fireworks is a social responsibility.

        1. Nice reply. I also have have animals that are terrified with the fireworks. And as to fingers, I actually did blow off two of my fingers in my childhood with fireworks. And lost the hearing in one ear. But even with that history, I would prefer to leave society itself to decide upon fireworks policy. I’m absolutely not one to advocate in any direction or the other. Besides, considering my past it would be highly hypocritical if I did :-)

          1. Wouldn’t you prefer that the fireworks were regulated better so that you could get to keep your fingers?

            In any case these are your fingers so you can decide what you like to do with them but I don’t want a wild firework entering my house thru the window and exploding in my living room where my kids play.

          2. It wouldn’t have made any difference. They were home made. It was another era.

            For the sake of my animals I would prefer they weren’t freely available. But I’m against a lot of over regulation because they screw up a lot of laws. Not relevant to any to this though.

            And there are a lot of laws that exist that I would have liked to have been enforced but they chose not to.

          3. For clarity, that was over 50 years ago in the 70’s in New Zealand.

            New Zealand only had really weak fireworks then in comparison to what is floating around in Europe now.

          4. My dog is afraid of fireworks. But I have no interest in limiting anyone’s enjoyment of them. I’m just working on re-training my dog. She wasn’t always this way. I don’t really understand what changed with her…

            @Salil Hen – Citation needed! It’s a big world, I am not going to say that a “wild firework” has never entered someone’s house. But I’ve certainly never heard of it. And people shoot them off pretty much every night from June through November where I live. Is that a common occurrence where you are from?

            Let’s not outlaw things as a solution for problems without at the very minimum first demonstrating that there even is a problem please!

        2. If noise affects your wellbeing, you might invest in some earplugs. Also, your animals? How about putting them up? Stop leaving them outside on the night of fireworks use? It’s more cruel for you to not take care of your animals health, than to blame someone else for celebrating. You sound like a Karen with that argument.

          1. “stop leaving animals outside on the night of fireworks”… I’m not sure my neighbours want to have several hundred sheep in their house.
            If you put a horse in it’s stable and it gets spooked it can try to kick it’s way out … injuring itself and needing to be put down.
            Nah I’m not going to suggest that round here. On fireworks nights people sedate their horses or stay out in the fields all night, while reminding people that in the UK it’s illegal to cause suffering to animals with fireworks. ( Pets or livestock)

            Suggesting people should take better care of their animals seems likely to provoke a Wicker Man reenactment.

          2. It’s not always something to make a law about, and I think a couple times a year is more than understandable, but you’re out of line.

            Surely you’ve at one time or another not wanted to sense something that someone was emitting? Maybe it was a bad smell, maybe it was a painfully bright light, but maybe it was a sound, whether it was someone being loud in general or talking politics at holiday dinner. Maybe you even felt violated by someone just coming into your personal space. It’s legitimate.

            Sounds are something you can sense even while asleep. You can’t fully block them out unless you’re 100% deaf. The most you can do even with uncomfortable strong hearing protection is to reduce them to a lower level. Active noise cancellation can’t do it either. Other than that you need to cover them up with your own even louder sounds; for instance music or white noise. Else you must listen to them unwillingly whether the particular noise sounds like sex or arguments or sirens or loud exhausts or gunshots. Not everyone is built in such a way that they aren’t stressed and bothered by being subjected to uncontrollable noise.

            Anyway, animals shouldn’t be expected to wear earplugs and taking them inside isn’t going to make them not panic, it’s just going to make them a bit less panicy and in large part due to company rather than because they care if the volume is a bit less. If they’re inclined to be scared of thunder, fireworks, and gunshots, they’re going to be scared of them even if they’re quieter but still plenty audible and are obviously still nearby.

        3. Why should I have to modify my activity just because you choose to have animals? And so what if they are scared a human shouldn’t have to modify their behavior for the sake of your scared dog.

          1. Because the earth is not your house, there are other beings living here that deserve some respect: birds that die just for your stupid, primitive game, war veteran with PTSD and autistic kids that get overwhelmed by the explosions. Why should do they suffer just because your primitive brain enjoy loud noises?

      2. Fun yea. Some kids here decided it’s okay to use fireworks all year long, especially when i put my kids to bed. Some other kids thought it was okay to throw fireworks to my kids. Ambulance personel and police cant do their work anymore during new year without protective gear due to the sheer amount of illegal fireworks. The list of abuse goes on and on. I actually thought of doing this project myself and I applaud someone for doing it first.

        I don’t have any issue with people using fireworks in a sane and fun way during new years. Things like this just tear out the fun for people that mean well.

          1. Licensed Paramedic working as a Deputy Sheriff here asking the same question… Not even sure what specialized fireworks protective gear they would be referring to.

            Alcohol is near 100% of our issues on or around new years.

      3. You sound like the person the entire neighborhood hates. Noise ordinances exist for a reason, and it’s not because people hate fun. You don’t care about pets, who are still terrified inside. You’re keeping people from sleeping. You’re torturing wild animals who have nowhere to run. For what? To celebrate? Please. Grow up.

        1. It’s already illegal to make noise after certain time. So banning fireworks basically because you choose to have scared pets is unfair. Why must I suffer because of your pets? Try having children instead of pets they would enjoy the fireworks.

      4. Then there’s the freedom of neighbors to consider. If I want to not have my kids and animals freaking out because my neighbor behind me has huge mortars and doesn’t know how to run a timely fireworks show, I just have to sit there and deal with it? People will pop them off for 6 hours, with 20 minutes breaks. I directly handle this infringement but it blows my mind that people think the nanny state is infringing on their rights but don’t consider the rights of others.

        If you’re very rural go for it. If you’re that easily entertained, go to a fireworks show and don’t be a jerk.

  1. someone in East San Jose lights off mortars nearly every time the Warriors or 49’ers win. Most of the city is concrete so there isn’t a lot of risk of fires, but if you’re a pilot flying near Reid–Hillview airport you might not appreciate the fireworks so much.

        1. You don’t fly low while in a landing pattern. That’s a noise issue over the city while you’re waiting for you landing slot.

          You only fly low on approach
          Is the approach path over the mortar?

  2. “… decided to put the technique to good use to track down the location of illicit fireworks launches.”
    In the interest of science and hobby engineering, a well-done project.”

    Attempting to confront the merry-makers is most definitely not recommended; likely to have one of those mortars aimed in your direction (or worst.) Even in ‘good’ neighborhoods people take a dim view of other neighbors interfering in their personal affairs.

      1. Abusive in what way? It’s *noise*. As long as they do it appropriately (like around acceptable days of celebration) you can’t do a damn thing about it. If you want peace and quiet, put in ear plugs.

        1. Are you suggesting *noise* can’t be abusive?

          “As long as they do it appropriately” part is the source of issue and it can render it abusive, isn’t it?

          (like around acceptable days of celebration) Who decides for that? Is the decision ultimate? Can’t it be improved? Who decided that at new years people can just use fireworks without any appropriate technical education (or 4th of July for that matter)? Can I do it on my birthday as well? Can I just drive a lorry without a licence on 5th of Augusts just because…?

    1. “people take a dim view of other neighbors interfering in their personal affairs.”

      Gotta love the hypocrisy of trying to defend fireworks with that “logic.” Reminds me of how “religious” and “small government” people are always the ones meddling in other people’s lives.

        1. at least they admit it and do so in the name of protecting others. unlike “small government” people who only care about what they want and hurt everyone else to get it

  3. The last I read the police funded projects largely failed, weather due to city landscape or too much noise to filter out? I like to ride a bike around downtown when they do the main show and note changes of all kinds of echoes and delays from one report as I move just a little.

    1. Best one I remember is from a fireworks show above a stadium with many tiers of hard seats, arranged in concave arcs. We were walking outside the stadium, and each BOOM was followed by a VERY loud CHIRP. I can’t remember if the chirps were rising or falling, but I’ll bet I could model it from the shape, position, and orientation of the seat rows…

        1. Yes! And I’m sure the effect there would be even stronger with fireworks, but I hope people don’t get in the habit of trying it. Doesn’t seem like it would be very good for the structure over the long term.

    1. I know,.right? The Karen’s are in the comment sections today. Give your animals their Xanax bars and put in some earplugs, or come out and celebrate with everyone like you are meant to.

      1. Drug up the animals and the kids so that you can “celebrate” by damaging your own hearing? Tell me more about this version of “civil society”.

        Will you be happy if the same neighbors pop out at 6AM on 1 Jan to start up the jackhammers for demo work on their driveway replacement?

        1. What is the alternative? All the random gunfire and shooting into the air that is standard in Latin America and the Middle East? This is already a problem in many US cities. The tradition of fireworks, celebrations, cannon fire, etc. comes from the leaders of the revolution like George Washington, who endorsed exuberant fireworks with risk of bodily harm.

      2. “…come out and celebrate they way *I* want you to.” is what you are really saying, right?
        Personal freedom only for you and those that think like you. Sounds like “Ultimate Karen” to me.

  4. Automatically finding peaks in a waveform is probably not the hardest part (Matlab has the findpeaks function for example). “Keeping everything time synchronized” is the key here, as you need to synchronize all your recording units to a common reference, precise in the ms-ns range, depending on the frequency you aim. Also, depending on the frequency as well, the amount of data recorded (if you you are not using a trigger) can quickly reach terabytes. Similar techniques are used to determine the source of an earthquake and monitor cracks in a structure (acoustic-wave monitoring).

    1. I have tested the software with a USB ultrasonic microphone (Pettersson). It works fine with an 8192 byte jackd buffer at I think it was 192khz. I could see a lot of interesting chirps on the spectrogram. Maybe mice, we had chickens then.

      I would like to test the effectiveness for locating bats for example. Even seeing if it can locate where the mice are in the backyard would be interesting.

      In testing I can regularly align the sounds from co-located microphones to less than 1ms of difference. Typically around 700 microseconds. It should be more because the system clock is much less than a microsecond of error on average but there’s some unaccountable buffer difference I think.

    2. When you detect a sound above some noise level you run a correlation with the other microphone outputs to get a very precise time relation. Draw circles (or spheres for a 3D location) around the microphones and look at the point where they all intersect.

      I have worked on this occasionally, calling it a “sound camera” in a 4 acre section of forest I have and track and locate deer and raccoons and birds, etc. The status now is the mesh network of 915MHz HopeRF tranceivers can’t handle the data. Maybe ESP32’s will do it.

  5. I can tell none of the commenters here live in AZ. With all the illegal fireworks going off pretty much 24/7 for like 4 months out of the year it’s like living in a Go* D*mn war zone. My dog spends the whole time either terrified or doped off his gord on Benedryl.

    The police are absolutely worthless. One Sheriff from a neighboring county was asked by a reporter about it and his answer was. “Well what do you expect us to do?”. Only in a lawless red state could LEO’s be so comfortable admitting that they have no intention of doing their jobs!

    If I get paid to do a job and flat out refuse to even attempt to do it I’m pretty sure that’s called stealing. If I thought that it would make a difference I’d set something like this up here. Unfortunately I’m sure that even if the cops bothered to show up and confiscate them they’d probably just light them off themselves.

    I’d sure be nice if we all could just pick and choose which laws we’d like to follow. Then we can see how good of an idea my pants optional Wednesdays would really be. Preceded by slap a cop Tuesday and followed closely by sunburnt wang Thursdays.

    1. “Only in a lawless red state could LEO’s be so comfortable admitting that they have no intention of doing their jobs!”

      As opposed to lawless blue states?
      B^)

  6. Actually, sound localizing fireworks is just good test data, I have not been providing the authorities the results of these tests. It provides insights as to what distance you can localize over and with what accuracy if you can hear the sound on several mics. What I would really like to do is make something for localizing the gunshots of poachers in Africa.

    I would also not recommend confronting people setting off fireworks. It is very interesting though to see the effectiveness of this tech.

    In addition to that, it can in principle be extended to localizing any sounds and in particularly sound localizing of different species is used in species studies in the field of bioacoustics.

    Kim Hendrikse

    1. Bravo! I’d LOVE to see this applied against poachers — although you really, REALLY need to be careful about confronting THEM.

      I’d also love to see it applied to localizing birdsong. I’ve seen FLIR’s “leak detectors” that use an array of ultrasonic mics to localize the hiss from gas leaks and overlay a highlight on an optical image. I’d love to see something that puts a circle around each bird that’s singing, tagged to the isolated song. Just a simple matter of signal processing, I’m sure… /s

  7. There are also other uses of this technology that can be considered “Less Karen”.

    In America, people have been convicted and jailed on the basis of sound localization technology alone, no other evidence. There was one case recently where a grandfather was jailed for almost a year. I would never advocate sound localization tech alone being used for convictions, I would even go so far as to say not even for evidence, reflections can make far too many errors.

    However, in this particular case, if the public were able to provide conflicting evidence with the official report it’s possible that this grandfather may not have been conflicted or at least freed earlier. Now there is a possibility for an alternative ground truth to that provided by the authorities in future cases.

    Clearly a less Karen use case :)

    KIm Hendrikse

  8. “but we’d love to see a version that automated comparing sound peaks across many disparate recording units”

    It’s called ‘shotspotter’, it’s deployed in several cities in the US – and it doesn’t work well at all.

    1. The technology appears to do what it is designed to do – it detects gun shots and tells you where they occurred.

      https://www.bridgedetroit.com/is-shotspotter-effective/

      Unfortunately, knowing where and when gun shots were fired doesn’t seem to help the police very much in catching bad guys.

      By the time the police get there, it’s all over. They can gather evidence that might help later, but the bad guys are long gone.

      Sadly, calls to 911 about gun shots don’t do any better.

      There’s some evidence of lower crime rates in areas with ShotSpotter, but there’s also evidence that areas covered by ShotSpotter receive fewer 911 calls for gun shot incidents – fewer people call to report incidents in areas with ShotSpotter.

      I’d say it works, it just doesn’t do any good.

  9. The company Shot Spotter charges cities Millions of dollars a year to monitor their microphones. This project could be a template for cities to make their own shot spotter systems, and cut out gigantic costs. The Shot Spotter company is really raking the cities over the coals. This could provide a low cost solution. Many cities take note. This is not very hard to build, and could save Millions a year.

  10. Fun project and I’ve definitely thought about this for tracking larger things like bolides and sonic booms, but I don’t have the budget to put up dozens of sensors.

    July 4th, los Angeles basically turns into a warzone. We’re also famous for being a literal tinderbox, and I live a block from the fire department. Oh and we have an emergency room doctor in the house too. So I can say the following: The fire department is busy, but I’ve only seen ONE grass fire in 10 years. And no reports of injuries. Of course it happens every year, but they didn’t end up in OUR hospital with stumps. Given the population, the density, and the incredible numbers of fireworks, you’d expect carnage, but it turns out that the biggest hazard is an AQI up in the 400s when the weather isn’t favorable and the dog pissing itself under the bed. All unpleasant things, but I’ll bet you’re more likely to get creamed by a drunk driver.

  11. Not a single comment about the actual process. Google: “code to locate infrasound signals” Multiple organizations continuously run code to detect and locate explosions, such as the CTBTO and volcano observatories. Real time data and some tools can be had for testing from sources such as this: https://www.iris.edu/hq/

    1. Inspirational write-up Kim!
      I live in the same province, with a few rotten apples, screwing it up for others by firing off heavier firework for more than a year now.
      Mostly after midnight, changing places.
      There are no government resources to track them down without digital help.

      1. Thanks! If you are living in Sittard-Geleen you could expand our group :-)

        Note, we are not going after these people it’s purely for insights and scientific curiosity.

  12. Cool project, and proud to be developed in .nl! Although this is a commercial product for quite some years: https://munisense.nl/documentatie/vuurwerkdetectie (in Dutch). While the technology works great and cost for operation is reasonable, the true cost lies in the manpower to enforce the fireworks policy and to caught perpetrators red handed. The systems were deployed during the holiday season in multiple cities across The Netherlands before the covid crisis.

  13. Here is a variation suggestion for sound based localization…. without all the state sponsored oversight and Karens with dogs… microphones set up around a long range target to determine the impact point of a bullet. The idea is for marksmanship at 300m or more where spotting scopes start getting shaky. Now you have all your microphones feeding into one processor. Absolute time is irrelevant, just relative time. The remote microphone challenge is eliminated. You are faced with relative timing accuracies to place a bullet within 1cm (or better) in a 2 square meter target area.

    1. So? What is your point? Some human characteristics transcend time and are a constant. Look at the 10 Commandments that characterizes human weaknesses and how to get along with others. Thousands of years old!!! The only variable is how the general secular society adhere to the “10 Suggestions”, or even comes about to think some of the points are perfectly OK.

    1. No, because it’s putting the power in the hands of the people not the government. First of all, the project is just scientific, it’s not telling the government anything.

      Secondly, what would you rather have, the government wtih microphones throughout the coutry or potentially people in small areas with microphones who had the choice what and how to inform the government if they chose to? Think in terms of the damage that can be done. With the government in control they can abuse the system for more than it’s initial intentions, with small groups of population, it’s more democratic, the scope of any damage if any would be limited to a very small area.

      If people do nothing, then it moves in the direction of the government doing this sort of thing. I think it’s better if the people themselves take actions so that government intervention is not done. Note, that’s too later for the Netherlands, the government there are already doing this.

      And note, the license in this project forbids government use except in wildlife preservation projects.

  14. It would be fairly trivial to test the system in Orange County, CA (or for that matter, Orange County, FL).

    Now I’m wondering if the system is accurate enough to distinguish between the various launch sites around the Disneyland and Walt Disney World Resorts, and tell how many shells were launched.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.