This repository contains the source code for a portable acoustic gunshot locator device. The system automatically detects gunshots, analyzes the acoustic signature, and calculates the direction and distance to the source of the gunfire. Article Source
The device operates by capturing and analyzing two distinct acoustic components of a gunshot:
- Shock wave - The N-shaped wave produced by supersonic bullets
- Muzzle blast - The explosive acoustic wave from the weapon discharge
Using a dual-microphone setup with a 34 cm acoustic base, the system calculates:
- Bearing angle to the shooter
- Distance to the shooter
- (Optional) Classification of weapon type
- Microcontroller: ARM Cortex-M4 (MK20DX256) @ 96 MHz
- Audio Module: SGTL5000 DAC (16-bit, 44.1 kHz sampling)
- Microphones: MKE-3 electret or compatible dynamic microphones
- Environmental Sensor: DHT22 (temperature/humidity)
- Memory:
- 23LC1024 external RAM
- MicroSD card for data storage
- Power: 1200 mAh Li-ion battery with TP4056 charge controller
- Compact design with simple user interface
- Environmental compensation for sound speed variations
- Real-time signal processing and location calculation
- Data logging to microSD card
- USB connectivity for data retrieval and device programming
- Battery-powered operation with LED status indicators
The system implements:
- Circular buffer recording (250ms @ 44.1kHz)
- Automatic threshold detection based on ambient noise level
- Shock wave and muzzle blast identification
- Time-of-arrival difference calculation between microphones
- Linear interpolation for high-precision timing
- Speed of sound calculation based on temperature and humidity
- Trigonometric calculations for position estimation
Laboratory tests confirmed:
- Bearing angle accuracy within ±2°
- Distance accuracy within 5 meters
- Clone this repository
- Install required libraries (STL, Arduino, AudioLibrary)
- Connect hardware components according to the schematic
- Compile and upload code to the microcontroller
GPL-3.0 license
- Peter Volgyesi, Gyorgy Balogh, Andras Nadas, Christopher B. Nash, Akos Ledeczi, "Shooter Localization and Weapon Classification with Soldier-Wearable Networked Sensors"
- T. Damarla, "Battlefield Acoustics"
- W. Choi, "Selective Background Adaptation Based Abnormal Acoustic Event Recognition for Audio Surveillance"
- L. Gerosa, "Scream and Gunshot Detection in Noisy Environments"
- Robert C. Maher, "Modeling and Signal Processing of Acoustic Gunshot Recordings"
- Owen Cramer, "The variation of the specific heat ratio and the speed in air with temperature, pressure, humidity, and CO₂ concentration"