drone-detection
What is it
A cheap device that listens to the 2.4 GHz band and tries to tell whether a drone controller is transmitting nearby. It uses an ESP32 and two nRF24L01+ radio modules, parts that together cost about 10–15 euros.
It started with the "bluejammers" that kept showing up online. I built one to see how they work and was surprised how effective it was. The obvious next question was how to detect one, and from there I moved to something rarer: detecting drones. When I looked around, I found very few projects, if any at all, that did it with hardware this simple and the way I wanted to.
How it works
┌──────────────┐ SPI2 ┌─────────┐ UART / CSV ┌──────────────────┐ │ nRF24L01+ #1 │────────▶│ │──────────────▶│ Python script │ │ ch 0 – 39 │ │ ESP32 │ DATA_LEFT:… │ noise floor │ ├──────────────┤ SPI3 │ │ DATA_RIGHT:… │ Wi-Fi filter │ │ nRF24L01+ #2 │────────▶│ │ │ live histogram │ │ ch 40 – 79 │ └─────────┘ └──────────────────┘ └──────────────┘
The nRF24L01+ is a simple transceiver, but it has a Received Power Detector (RPD) register. It's one bit that goes to 1 when the radio hears anything stronger than about −64 dBm on its current channel. That's enough to build a dumb spectrum analyzer:
- Switch the radio to a channel (1 MHz wide, 2400–2479 MHz).
- Wait for the PLL to settle, toggle CE, listen for ~200 µs.
- Read RPD. If it's set, add one hit to that channel's counter.
- Move on to the next channel.
Two radios on separate SPI buses split the band: one covers channels 0–39, the other 40–79. The ESP32 runs 50 sweeps, then sends both histograms over UART as a CSV line (DATA_LEFT:3,0,1,…) and starts again.
On the PC, a Python script reads the stream and plots it live. That's where detection happens for now:
- Noise floor: the median of all channels plus a margin. Anything above it is a spike.
- Wi-Fi filter: Wi-Fi occupies ~20 MHz, so it lights up many neighbouring channels at once. If five or more adjacent channels are high, the spike is ignored.
- Drone: a narrow spike that doesn't fit the Wi-Fi shape. Drone controllers use frequency hopping (FHSS): short, narrow bursts that jump across the band much faster than Wi-Fi.
How I built it
I wrote the driver from scratch on top of ESP-IDF instead of using an Arduino library. I wanted to understand what actually goes over SPI. The goal was to make something built specifically for this purpose and extremely fast, which is why I'm planning to port the detection to C once testing is done and I've found the right algorithm.
- ESP-IDF boilerplate, GPIO init, first CMake setup.
- SPI bus configuration and raw register read/write. First successful read of the CONFIG register – proof the wiring works.
- Moved all SPI and register logic out of main.c into a separate nrf24 component with a small API.
- Power management and channel activity detection through the RPD bit.
- Full channel sweep with a hit histogram per channel.
- Second radio on its own SPI host, both scanning in parallel.
- Replaced debug printing with a CSV stream the PC side can parse.
- Python tool for live plotting and tuning the detector.
- Each radio scans its own half of the band, so a full sweep takes half the time.
- Fixed false positives: CE has to be toggled before sampling RPD, otherwise the bit carries over from the previous channel.
The current approach: the ESP32 is only a fast scanner that streams raw data, and the detection logic lives in Python where it's quick to change and see the result. Once the thresholds and the algorithm are tuned, I'll port them to C so the device works on its own, without a computer, and eventually with its own display.
Hardware
ESP32 DevKit V1 + 2× nRF24L01+.
| signal | left radio (SPI2) | right radio (SPI3) |
|---|---|---|
| MISO | GPIO 19 | GPIO 12 |
| MOSI | GPIO 23 | GPIO 13 |
| SCLK | GPIO 18 | GPIO 14 |
| CSN | GPIO 21 | GPIO 15 |
| CE | GPIO 22 | GPIO 16 |
The nRF24 modules are very sensitive to power noise. A 10–100 µF capacitor soldered directly across VCC and GND of each module made a clear difference. They also need 3.3 V, not 5 V.
Roadmap
- Bare-metal SPI driver
- Dual-radio support
- High-speed channel scanning (0–79)
- Python visualization and tuning tool (working, still tuning)
- FHSS detection algorithm ported to C
- Standalone handheld device on its own PCB
Built for learning and research only. Monitoring the 2.4 GHz band is passive, but local radio regulations still apply.