Mine detection using swarm drones

Published Jun 17, 2026
 720 hours to build
 Intermediate

I built a group of 4 swarm drone,which can help us to detect mines in minefield and navigate us to cross mine field with safest path

display image

Components Used

Raspberry Pi 5 4GB
Single Board Computer 2.4GHz 4 Core 4GB RAM Broadcom BCM2712 Arm Cortex-A76
4
ESP32 WROOM
WiFi Development Tools - 802.11 ESP32 General Development Kit, embeds ESP32-WROOM-32E, 4MB flash.
4
LIPO Battery 11.1V
Battery Packs LIPO Battery 11.1V 1000mAh LB-010
4
Darkmatter h760 flight controller
It is a drone flight controller
4
Drone frame
Structural body supporting all drone components.
4
BLDC Motors
16
Pi camera v3
4
Elrs radio recever
4
Radiolink m10n GPS
4
Drone propeller
16
Description

 

Mine Detection Using Autonomous Swarm Drones

A fully autonomous four-drone swarm for aerial landmine detection using YOLOv11 and GPS-tagged reporting

 

1. Introduction

Landmines remain one of the most dangerous post-conflict hazards worldwide. Manual detection is slow, hazardous, and expensive. This project presents a fully autonomous swarm of four drones — one Leader and three Followers — capable of surveying large open areas, detecting buried mine-like objects using a trained deep-learning model, and logging precise GPS coordinates of each detection without any human entering the danger zone.

 The entire system is designed around commodity hardware: Raspberry Pi 5 companion computers, Braahma H7 ArduPilot flight controllers, ESP32 wireless modules, and Pi Camera Module 3 units. All software is written in Python and runs without any cloud dependency.

 

CORE IDEAOne operator points in a direction using a hand gesture. All four drones take off, form a sweep line, fly 100 m in that direction, scan the ground with AI, geo-tag every mine found, and land automatically.

 

1.1  Why a Swarm?

A single drone covers a narrow strip per pass. Three follower drones flying side-by-side at 6.67 m lateral spacing multiply the effective sweep width by approximately 3×, cutting total survey time for a fixed area by the same factor.

 

1.2  Why GPS?

A YOLOv11n model fine-tuned on mine imagery detects objects in each camera frame. The pixel position of every detection is converted to real-world GPS coordinates using the drone's altitude, camera field-of-view, and magnetic heading. A 2 m GPS-radius deduplication algorithm merges repeated sightings of the same mine into a single averaged coordinate, producing a clean, accurate mine map at mission end.

 



 

2. System Overview

2.1  Automated Mission Phases

PhaseActorDescription
1 — TakeoffAll dronesDrones arm and climb to 3 m hover altitude.
2 — FormationLeader + FollowersFollowers GPS-navigate to positions: 3 m behind leader, ±6.67 m lateral.
3 — Gesture InputLeader onlyPi Camera reads operator open-palm gesture to select flight direction.
3.5 — ClimbAll dronesClimb to 5.1 m mission altitude for optimal mine-camera ground coverage.
4 — Forward FlightAll dronesFly 100 m in chosen direction at 1 m/s. Followers run YOLO mine detection.
5 — HoverAll drones15-second hover. Followers transmit mine GPS data to leader via ESP-NOW.
6 — Land FollowersLeader commandsFollowers land. Leader waits for all MINE_DONE confirmations.
7 — Leader RTLLeaderLeader returns to launch. Full CSV mine report saved to disk.

 

2.2  Communication Architecture

All drone-to-drone communication uses ESP-NOW — a lightweight, connectionless 2.4 GHz protocol by Espressif. Each Raspberry Pi connects to an ESP32 module via UART at 115200 baud. The ESP32 acts as a transparent wireless bridge so the Pi only sends and receives plain text messages.

 

DirectionMessages
Leader → FollowersARM, TAKEOFF, FORMATION, HEADING:<deg>, START_MOVE, STOP_MOVE, LAND
Followers → LeaderREADY, STATUS:<data>, MINE:<lat>,<lon>,<conf>, MINE_DONE
HeartbeatFollowers send periodic heartbeat. Leader triggers emergency land on timeout (10 s in air).

 


3. Hardware Components

 3.1  Components List  (identical across all four drones)

 

#ComponentSpecificationRole
1Quadcopter Frame250–350 mm wheelbaseStructure
2Raspberry Pi 54 GB RAM, 64-bit ARMMission computer / AI inference
3Braahma H7 FCSTM32H7, ArduPilot firmwareFlight control + MAVLink
4GPS ModuleM10 or M8N, 10 Hz updatePosition and heading source
5ESP32 Dev BoardESP32-WROOM-32ESP-NOW wireless mesh
6Pi Camera Module 312MP IMX708, HFOV 66°Mine detection (downward-facing)
7Brushless Motors2205–2306, 2300–2450 KVPropulsion (×4)
8ESC30–35A BLHeli32 (×4)Motor speed control
9LiPo Battery4S, 3000–4000 mAh, 45C+Power supply
10Passive Buzzer3.3V, small PCB moduleAudio status feedback
11microSD Card32 GB Class 10 / U3OS + captured image storage

 

3.2  Software & Libraries

 

Library / ToolVersionPurpose
Python3.11 + 3.13Primary language (two versions needed on leader for camera pipeline)
DroneKit2.9.xMAVLink / ArduPilot high-level Python API
pymavlink2.4.xLow-level MAVLink message encoding
Picamera20.3.xRaspberry Pi Camera Module 3 driver (Python 3.13)
OpenCV4.8+Image capture, colour conversion, frame saving
Ultralytics YOLO8.x (v11n)Mine object detection inference on-device
MediaPipe0.10.xHand landmark detection for gesture input (Python 3.11)
lgpio0.2.xGPIO buzzer control (Pi 5 compatible, replaces RPi.GPIO)

 

4. Circuit Connections

 

 

4.1  Pin Connection Table

 

Raspberry Pi 5 PinSignalConnects ToDevice Pin
GPIO14 / Pin 8UART0 TXBraahma H7SERIAL1 RX
GPIO15 / Pin 10UART0 RXBraahma H7SERIAL1 TX
Pin 6 — GNDGNDBraahma H7GND
GPIO4  / Pin 7UART2 TXESP32GPIO16  (RX2)
GPIO5  / Pin 29UART2 RXESP32GPIO17  (TX2)
Pin 14 — GNDGNDESP32GND
GPIO18 / Pin 12SignalBuzzerSignal pin
Pin 1 — 3.3VVCCBuzzerVCC pin
Pin 14 — GNDGNDBuzzerGND pin
CSI portRibbonPi Camera M3CSI connector

 

 

 

4.2  Enabling UART on Raspberry Pi OS

Add the following lines to /boot/firmware/config.txt, then reboot:

   enable_uart=1          # enables UART0 on GPIO14/15
  dtoverlay=uart2        # enables UART2 on GPIO4/5
  dtoverlay=disable-bt   # frees UART0 from Bluetooth

 

5. Software Architecture

The codebase is split into eight Python files with a single clear responsibility each. All files share a common config (config.py) and utility library (common.py).

 

FileRuns OnResponsibility
config.pyAll dronesSingle source of truth for every constant — altitudes, speeds, timeouts, pins, file paths.
common.pyAll dronesSharedState thread bus, GPS math, MAVLink velocity / yaw helpers, buzzer driver.
leader.pyLeader Pi7-phase mission sequencer, gesture trigger, mine CSV aggregator.
follower.pyFollower Pi ×3Formation flight, command parser, MineDetector thread lifecycle.
gesture.pyLeader PiLaunches camera pipeline subprocess, receives UDP result, returns snapped angle.
camera_sender.pyLeader PiCaptures 640×480 JPEG frames at 10 FPS, writes to stdout as length-prefixed packets.
gesture_detector.pyLeader PiReads piped frames, runs MediaPipe Hands, sends POINTING or TIMEOUT via UDP :9999.
mine_detector.pyFollower Pi ×3Daemon thread: YOLO inference, pixel→GPS conversion, GPS dedup, results buffer.

 

5.1  SharedState — Thread-Safe Data Bus

 

Both the FlightThread and CommThread in every drone share data through a single SharedState object. All reads and writes are protected by a threading.Lock. The get_snapshot() method reads multiple fields atomically in one lock acquisition — this prevents the classic GPS race condition where reading latitude and longitude in separate operations can yield mismatched values if a GPS update arrives in between.

 

5.2  Gesture Detection Pipeline

 

When the leader reaches Phase 3, it spawns two subprocesses connected by a Unix pipe:

 

  • camera_sender.py (Python 3.13) — captures frames from Pi Camera Module 3 and writes them to stdout as [4-byte big-endian length][JPEG bytes] packets at 10 FPS.
  • gesture_detector.py (Python 3.11) — reads frames from stdin, runs MediaPipe Hands, detects an open palm (all five fingers extended), and sends "POINTING:<angle>" or "TIMEOUT" as a UDP datagram to 127.0.0.1:9999.
  • gesture.py — receives the UDP result, snaps the raw angle to the nearest 45° (8 compass directions), beeps the buzzer for confirmation, and returns the direction to the FlightThread.

 

5.3  Mine Detection (Follower Drones)

When START_MOVE is received, each follower starts a MineDetector daemon thread alongside its FlightThread. The sequence is:

  1. Open Pi Camera Module 3 and load YOLOv11n model (normal.pt).
  2. Capture frames continuously (~15–20 FPS; YOLO inference takes ~100 ms per frame on Pi 5).
  3. For each detected bounding box: compute pixel-centre offset from image centre, scale by metres-per-pixel (derived from altitude and camera FOV), rotate by drone heading, add to drone GPS position.
  4. Deduplication: if the new mine GPS is within 2 m of an existing entry, update the running average position; otherwise add a new mine record.
  5. On STOP_MOVE: stop capture, send all unique mines to leader as MINE messages via ESP-NOW, then send MINE_DONE.

 

5.4  Pixel-to-GPS Conversion

The core math converting a bounding-box pixel centre to a GPS coordinate:

 

 

  # Ground footprint at current altitude
  ground_w = 2 * altitude * tan(HFOV_rad / 2)   # metres across frame
  ground_h = 2 * altitude * tan(VFOV_rad / 2)   # metres down frame
  mpp_x   = ground_w / image_width             # metres per pixel
  mpp_y   = ground_h / image_height
 
  # Offset of detection from image centre (camera frame)
  u = (cx - width/2)  * mpp_x   # East (+right)
  v = -(cy - height/2) * mpp_y   # North (+forward)
 
  # Rotate camera frame by drone magnetic heading
  north = v * cos(heading_rad) - u * sin(heading_rad)
  east  = v * sin(heading_rad) + u * cos(heading_rad)
 
  # Apply offset to drone GPS position
  mine_lat = drone_lat + north / 111320.0
  mine_lon = drone_lon + east  / (111320.0 * cos(radians(drone_lat)))



 

6. Step-by-Step Build Guide

 

Step 1 — Assemble the Drone Frame

 

  • Mount brushless motors on the four arms in X-frame order: front-left and rear-right spin CCW; front-right and rear-left spin CW.
  • Solder ESCs to the power distribution board or directly to the main battery lead using XT60 connectors.
  • Mount the Braahma H7 flight controller at the frame centre on anti-vibration rubber standoffs.
  • Connect each ESC signal wire to FC motor outputs M1–M4.
  • Mount the GPS module on a riser mast at least 5 cm above the FC to reduce magnetic interference.

 

Step 2 — Mount Companion Computer and Peripherals

 

  • Secure the Raspberry Pi 5 above the FC on nylon standoffs; keep it away from ESC heat sources.
  • Mount Pi Camera Module 3 facing straight down through the frame opening, rigidly fixed with no play.
  • Route the CSI ribbon cable carefully — avoid sharp bends, especially near the connectors.
  • Mount the ESP32 on a small prototyping PCB with UART2 header pre-soldered.
  • Hot-glue the passive buzzer to the frame and run short wires to GPIO18 and GND.

 

Step 3 — Wire All Connections

 

Follow the connection table in Section 4.1 exactly. Critical reminders:

  • UART0 (Pi GPIO14/15) ↔ Braahma H7 SERIAL1 — main flight-controller link.
  • UART2 (Pi GPIO4/5) ↔ ESP32 Serial2 (GPIO16/17) — mesh communication link.
  • All grounds must be common — tie Pi GND, FC GND, and ESP32 GND together.
  • Double-check TX↔RX cross-connection before powering on.

 

Step 4 — Configure ArduPilot on Braahma H7

  • Flash ArduCopter firmware using Mission Planner or QGroundControl via USB.
  • Set SERIAL1_PROTOCOL = 2 (MAVLink 2) and SERIAL1_BAUD = 115.
  • Calibrate accelerometer, compass, RC, and ESCs through Mission Planner.
  • Verify 3D GPS lock and check all pre-arm conditions clear before any test.

 

Step 5 — Set Up Raspberry Pi OS

Flash Raspberry Pi OS 64-bit (Bookworm) to the microSD card, then run:

 


  sudo apt update && sudo apt upgrade -y
 
  # Enable camera via raspi-config
  sudo raspi-config   # Interface Options -> Camera -> Enable
 
  # Add to /boot/firmware/config.txt:
  #  enable_uart=1
  #  dtoverlay=uart2
  #  dtoverlay=disable-bt
 
  sudo reboot

 

 

Step 6 — Install Python Dependencies

 

 

  # All Pis — common packages
  pip3 install dronekit pymavlink ultralytics opencv-python lgpio
 
  # Leader Pi only — gesture pipeline
  # Python 3.11 for MediaPipe
  pip3.11 install mediapipe opencv-python
 
  # Python 3.13 for Picamera2
  pip3.13 install picamera2 opencv-python
 
  # Fix dronekit collections compatibility (Python 3.10+)
  # Add these 3 lines at the top of follower.py and leader.py:
  # import collections, collections.abc
  # collections.MutableMapping = collections.abc.MutableMapping
  # collections.Iterable = collections.abc.Iterable

 

Step 7 — Deploy Code Files

 

 

  # Leader Pi
  scp config.py common.py leader.py gesture.py \
      camera_sender.py gesture_detector.py  pi@<LEADER_IP>:~/swarm/
 
  # Each Follower Pi  (edit DRONE_ID = 1, 2, or 3 before copying)
  scp config.py common.py follower.py mine_detector.py normal.pt \
      pi@<FOLLOWER_IP>:~/swarm/
 
  # Create output directories
  mkdir -p ~/swarm/mine_reports          # on leader
  mkdir -p ~/swarm/thermal/captures      # on each follower

 

 

Step 8 — Flash ESP32 Firmware

 

  • Flash each ESP32 with an ESP-NOW UART bridge sketch via Arduino IDE or PlatformIO.
  • The firmware reads bytes arriving on Serial2 (115200 baud) and broadcasts them to all registered ESP-NOW peers; received ESP-NOW packets are forwarded back to Serial2.
  • Register all four ESP32 MAC addresses as peers in the firmware before flashing.

 

Step 9 — Pre-Flight Checks

 

  • Power each Pi and confirm /dev/ttyAMA0 and /dev/ttyAMA2 appear in ls /dev/ttyAMA*.
  • Run mine_test.py on a follower on the bench (props off) to verify Camera + YOLO + GPS GPS coordinates are producing valid output.
  • Run a bench test: start follower.py on all followers, then leader.py on leader. Without props, verify ARM, TAKEOFF, FORMATION commands flow and followers acknowledge.
  • Check LiPo voltage ≥ 15.5V on each 4S pack before every flight.

 

Step 10 — Run the Mission

 

 

  # On each Follower Pi — start BEFORE leader
  cd ~/swarm && python3 follower.py
 
  # On Leader Pi
  cd ~/swarm && python3 leader.py
 
  # Leader waits for all three followers to report READY
  # Then prompts: 'Start mission? (y/n)'
  # Type y and press Enter
  # Swarm arms, takes off, and completes the mission fully autonomously
  # Mine CSV report saved to ~/swarm/mine_reports/ after landing

 


7  Sample Mine Report Output  (CSV)

 

 

  mine_id, follower_id,        avg_lat,    avg_lon,  best_conf, avg_alt, sightings,   best_img
  Mine-1,      1,           23.02851234, 72.57140012, 0.87,      5.1,     14,       frame_0032_14-32-01-445.jpg
  Mine-2,      2,           23.02834512, 72.57213400, 0.72,      5.1,      8,       frame_0051_14-32-18-112.jpg
  Mine-3,      3,           23.02872100, 72.57189900, 0.91,      5.1,     21,       frame_0077_14-32-40-880.jpg

 

8 video

 

Codes

Downloads

Block diagram of all connection Download
circuit Download
Mine_Detection_Swarm_Drones_detailed_description Download
Comments
Ad