🚁 MODULE 3: DRONE TRACK • SESSION 12 / 12 (CAPSTONE)

Session 12: Sonar Altitude Hold & Eco-Seed Cargo Drop (Capstone)

The ultimate capstone flight mission! Combine HC-SR04 ultrasonic sonar for automatic 50cm altitude hover with an SG90 micro-servo payload release latch to execute a precision eco-seed reforestation air-drop.

⚡ 4-Step Capstone Mission Architecture

Sonar Precision Hover • Servo Payload Release
Step 1 📡
Downward Sonar Beam
HC-SR04 (40kHz Echo)

Pings ground surface 25 times/sec to measure exact height.

Step 2 🎯
50cm Altitude Hold
Auto-Throttle PID Loop

Modulates collective thrust to lock rock-solid hover at 50cm.

Step 3 📍
Drop Zone Trigger
Target Zone Reached

Pilot verifies stable hover over designated green target zone.

Step 4 🌱
SG90 Cargo Release
Servo 0° ➔ 90° Open

Drops eco-seed cargo capsule with pinpoint delivery accuracy!

1

🧰 Capstone Mission Hardware Tray

ESP32-S3 Dev Board
ESP32-S3 Flight Brain
Orchestrates IMU, sonar altimeter, and servo payload gate.
HC-SR04 Ultrasonic Sonar
HC-SR04 Sonar Altimeter
Facing downwards to measure ground clearance (Trig 12, Echo 13).
SG90 Micro Servo
SG90 Payload Servo
Micro servo driving mechanical eco-seed payload drop latch.
Complete Mission Quadcopter
Autonomous Mission Drone
Full quadcopter loaded with eco-seed package ready for launch.
2

🎯 Interactive 50cm Sonar Altitude Hold & Eco-Seed Cargo Drop Simulator

Autonomous Hover Sonar maintains 50cm altitude • Click button to trigger cargo drop
🎯 TARGET ZONE TARGET HOVER: 50 cm ESP32-S3 SONAR 50cm 🌱
🎯 Target Altitude Setpoint 50 cm (Locked)
Measured Altitude
50.2 cm
HC-SR04 Sonar
Hover Throttle
58%
PID Auto-Comp
Servo Drop Latch
0° LOCKED
Pin 14 PWM
Mission Payload
ARMED
Ready to Drop
3

🔌 Capstone Mission Circuit & Wire Map

Capstone Drone Wiring Diagram ESP32-S3 + HC-SR04 Sonar + SG90 Servo Latch + Quad Motors
HC-SR04 VCC & Servo Red
Red Jumper Wire to 5V / VIN Rail
5V / VIN
Common Ground (GND)
Black Jumper connecting Sonar GND, Servo Brown, and ESP32
Common GND
Sonar Trigger (Trig)
Yellow Jumper Wire from ESP32 to HC-SR04 Trig
GPIO 12
Sonar Echo (Echo)
Green Jumper Wire from HC-SR04 Echo to ESP32
GPIO 13
SG90 Servo Latch Signal
Orange Jumper Wire to Servo Control Pin
GPIO 14
4

⚡ Final Capstone Compile-Verified Codes

step1_sonar_altitude_hold.ino ESP32-S3 38 lines
/*
 * Session 12 - Step 1: Downward Ultrasonic Sonar 50cm Altitude Hold PID
 * Wiring: Downward HC-SR04 TRIG -> GPIO 12 | ECHO -> GPIO 13
 */
#define TRIG_PIN 12
#define ECHO_PIN 13
#define RGB_PIN  48
Preview (8 of 38 lines) — Click ⚡ Open in IDE to auto-load code & ESP32-S3 board!
✅ Output: Move drone up/down ➔ PID auto-adjusts hover PWM to lock at 50cm (Green RGB)!
step2_servo_cargo_drop.ino ESP32-S3 33 lines
/*
 * Session 12 - Step 2: Aerial Eco-Seed / Cargo Drop Mechanism (SG90 Servo on GPIO 14)
 * Send 'D' in Serial Monitor (or trigger over Wi-Fi) to release cargo payload!
 */
#define SERVO_PIN 14
#define RGB_PIN   48

void setLatch(int angle) {
Preview (8 of 33 lines) — Click ⚡ Open in IDE to auto-load code & ESP32-S3 board!
✅ Output: Send D in Serial Monitor ➔ SG90 releases eco-seed cargo latch cleanly!
step3_preflight_self_test.ino ESP32-S3 44 lines
/*
 * Session 12 - Final Showcase: Automated Pre-Flight Drone Self-Test Suite
 * Verifies MPU-6050 I2C (0x68), Downward Sonar (cm), Cargo Servo (14), & 4-Motor Check!
 */
#include <Wire.h>
#define MPU_ADDR  0x68
#define TRIG_PIN  12
#define ECHO_PIN  13
Preview (8 of 44 lines) — Click ⚡ Open in IDE to auto-load code & ESP32-S3 board!
✅ Output: Runs automated MPU-6050 + Downward Sonar + Cargo Servo pre-flight diagnostics!
5

💡 Capstone Flight & Aerospace Viva Questions

Q1: Why is ultrasonic sonar used for low-altitude hover instead of GPS?

Standard commercial GPS has a vertical altitude accuracy error of ±2.5 meters and does not work indoors inside classrooms or auditoriums. Ultrasonic sonar has millimeter-level precision (±2mm) and operates by reflecting physical sound waves off the floor, making it ideal for indoor precision hover.

Q2: What is the "Ground Effect" in drone aerodynamics?

When a drone hovers very close to the floor (less than 1 rotor diameter, ~15cm), the downward rotor wash air is trapped against the ground, creating a high-pressure air cushion that pushes the drone up with less power. The PID altitude controller automatically reduces throttle in Ground Effect to maintain exact 50cm setpoint.

Q3: What makes this Connect Robo Super-Kit capstone project real-world relevant?

This project mirrors real-world autonomous delivery drones (like Zipline medical supply drops) and agricultural eco-restoration drones that plant forests by dropping seed capsules into remote deforested zones with autonomous altitude holding.

📥 33 Sketches (.ZIP) ← Previous: Session 11 (Wi-Fi Phone Flight & Failsafe) 🎓 Graduation: Return to Super-Kit Book Index →