How to build an ESP32 drone step by step instructions and code

How to Build a Mini Drone with ESP32 | Fun Robotics Project for Kids
🤖 Fun Robotics Project for Kids

How to Build Your Own ESP32 Mini Drone! 🚁

A super fun, step-by-step guide to building a real flying drone with circuit diagrams and code!

🛠️ 🔋 📡 ✨

📚 What's Inside This Guide

  1. What is an ESP32 Drone?
  2. Parts You'll Need
  3. Safety First!
  4. Circuit Diagram
  5. Step-by-Step Building Instructions
  6. The Drone Code
  7. How to Fly It
  8. Frequently Asked Questions

🌟 What is an ESP32 Drone?

An ESP32 drone is a small flying robot controlled by a tiny computer chip called the ESP32. This chip is like the drone's brain — it tells the motors how fast to spin so the drone can take off, hover, and fly around! ESP32 chips are perfect for beginners because they're cheap, small, and have built-in Wi-Fi, so you can even control your drone using your phone or laptop.

This project is great for school science fairs, STEM clubs, or just having fun with your family on a weekend!

🧰 Parts You'll Need

Ask a grown-up to help you order these parts online. Here's your shopping list:

💻
ESP32 Dev Board
🌀
4 Coreless Motors
🪶
4 Mini Propellers
🔌
4 Motor Drivers (MOSFETs)
🔋
1S LiPo Battery (3.7V)
🧭
MPU6050 Gyroscope
🏗️
Drone Frame (Mini Quad)
🧵
Jumper Wires
Part NameWhat It Does
ESP32 Dev BoardThe brain of the drone
MPU6050 SensorHelps the drone balance
Coreless Motors (x4)Spin the propellers
Mini Propellers (x4)Push air down to fly
LiPo Battery 3.7VPowers everything
Drone FrameHolds it all together
⚠️ Safety First, Little Engineers!
  • Always build this project with a parent or teacher.
  • Keep fingers away from spinning propellers.
  • Never touch the battery terminals together (it can spark!).
  • Fly your drone outdoors or in a big open room, away from people and pets.

🔌 ESP32 Drone Circuit Diagram

Here's how all the parts connect to your ESP32 board. Follow the colors carefully!

ESP32 Dev Board LiPo 3.7V MPU6050 Gyroscope (I2C) Motor 1 Motor 2 Motor 3 Motor 4 Motors connect through MOSFET drivers to ESP32 GPIO pins

📍 Pin Connections

ESP32 PinConnects To
GPIO 13Motor 1 driver
GPIO 12Motor 2 driver
GPIO 14Motor 3 driver
GPIO 27Motor 4 driver
GPIO 21 (SDA)MPU6050 gyroscope
GPIO 22 (SCL)MPU6050 gyroscope
VINBattery positive (+)
GNDBattery negative (−)

🛠️ Step-by-Step Building Instructions

1Build the frame. Snap together the drone frame's arms in an X shape. This is where your motors will sit.
2Attach the motors. Screw one motor to the end of each arm. Make sure all 4 motors face the same direction.
3Mount the ESP32 board. Place the ESP32 in the center of the frame using small zip ties or double-sided foam tape.
4Connect the gyroscope. Attach the MPU6050 sensor next to the ESP32 and wire it to the SDA and SCL pins.
5Wire the motors. Connect each motor to its MOSFET driver, then connect the driver to the matching GPIO pin on the ESP32.
6Add the propellers. Push the propellers onto the motor shafts — make sure two spin clockwise and two spin counter-clockwise!
7Connect the battery. Plug in the LiPo battery to power the ESP32 and motors. Double-check polarity before connecting!
8Upload the code. Connect ESP32 to your computer with a USB cable and upload the program below using the Arduino IDE.

💻 The Drone Code (Arduino/ESP32)

This beginner-friendly code reads the gyroscope and balances the drone's motors. Copy it into your Arduino IDE!

#include <Wire.h>
#include <MPU6050.h>

MPU6050 mpu;

// Motor pins
const int motor1 = 13;
const int motor2 = 12;
const int motor3 = 14;
const int motor4 = 27;

int baseSpeed = 150; // starting motor speed (0-255)

void setup() {
  Serial.begin(115200);
  Wire.begin();
  mpu.initialize();

  pinMode(motor1, OUTPUT);
  pinMode(motor2, OUTPUT);
  pinMode(motor3, OUTPUT);
  pinMode(motor4, OUTPUT);

  Serial.println("Drone ready for takeoff!");
}

void loop() {
  int16_t ax, ay, az, gx, gy, gz;
  mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);

  // Simple balance logic using gyroscope tilt
  int correction = gx / 100;

  int speed1 = constrain(baseSpeed + correction, 0, 255);
  int speed2 = constrain(baseSpeed - correction, 0, 255);
  int speed3 = constrain(baseSpeed + correction, 0, 255);
  int speed4 = constrain(baseSpeed - correction, 0, 255);

  analogWrite(motor1, speed1);
  analogWrite(motor2, speed2);
  analogWrite(motor3, speed3);
  analogWrite(motor4, speed4);

  delay(20);
}

What this code does: it reads tilt data from the gyroscope and gently speeds up or slows down opposite motors to keep the drone level — just like the drone's own sense of balance!

🚀 How to Fly Your ESP32 Drone

  1. Place your drone on a flat, open surface (outdoors is best).
  2. Turn on the battery switch and stand back.
  3. Watch the propellers spin up slowly first to test balance.
  4. Once steady, you can connect your phone to the ESP32's Wi-Fi to control throttle and direction (advanced step!).
  5. Always land gently and turn off the battery after each flight.

❓ Frequently Asked Questions

Q: Is this project safe for kids?

Yes, with adult supervision! Younger kids should focus on building while an adult handles soldering and wiring.

Q: Can I control the drone with my phone?

Yes! Since the ESP32 has built-in Wi-Fi, you can create a simple web app to send commands wirelessly.

Q: Why isn't my drone flying straight?

Check that your propellers spin in the correct directions and that the gyroscope wiring (SDA/SCL) is connected properly.

Q: How long does the battery last?

A small 3.7V LiPo battery typically powers a mini ESP32 drone for about 5–8 minutes of flight time.

🚁 Made with curiosity and code — Happy Building, Future Engineer! 🚁

Comments

Product Cards
Buddy Bot eBook
⭐ New 2026 Release
Build Your
Own Robot!
3D design, wiring &
Arduino coding.
Young inventors love it!
🖨️
3D Print
All parts
Wire it
Circuit guide
💻
Code it
Arduino IDE
🤖
Watch it
Walk & react
📋 Your Details
Enter your name
Valid 10-digit no.
Enter a valid email
Special Website Offer
₹499 300
🌍 International: $5 USD
One-time · Instant digital delivery
🔒 Secured by Razorpay · Your data is safe
📄 Download Free Sample Copy
🔒 Secured by Razorpay · Your data is safe
🍓
Raspberry Pi Pico Mastery
21 Projects
⚡ Launch Price — 80% OFF
Learn Pico
Build 21 Projects!
MicroPython · Wokwi
IoT · Certificate
Perfect for beginners!
🖥️
Wokwi
No hardware
🐍
MicroPy
From zero
🔨
21 Projects
IoT + sensors
📄
Certificate
Verified cert
📋 Your Details
Enter your name
Valid 10-digit no.
Enter a valid email
Special Launch Offer
₹999 200 80% OFF
🌍 International: $5 USD
One-time · Lifetime access · No subscription
🔒 Secured by Razorpay · UPI · Cards · NetBanking
🎉

You're in!

Payment successful! Your Buddy Bot eBook is ready. Time to build!

📖 Access Your eBook Now
🎉

Enrolled!

Payment successful! Lifetime access to all 21 Pico Projects is yours!

🍓 Go to My Course