Phone-controlled ESP32-C3 drone

A small quadcopter with no radio: the ESP32 creates its own Wi-Fi network and serves the control page to your phone. Here are the parts I used, the wiring and the tests to run before the propellers go on.

The drone control page: throttle on the left, direction on the right, ARMAR (arm) and PARAR E DESARMAR (stop and disarm)
The control page, served by the ESP32 itself.
Board
ESP32-C3-Zero
Sensor
MPU6050
Motors
4 × brushed 716
Battery
LiPo 1S, 1000 mAh
Control
Phone, over Wi-Fi
Control loop
250 Hz

Project status

Experimental. It takes off and keeps itself level, but it doesn't hold altitude or position: left alone, it drifts. Build it knowing that.

Parts

This is the list of what goes into the drone. Some parts have purchase links, which are affiliate links: if you buy through them, I earn a commission and you pay the same price. Listings change, so check the specs before you buy.

The values are the ones I used, as a reference: you can use equivalents, and a lot of this can come from scrap, like motherboards, PC power supplies and old toys. Where there are alternatives, they are listed with the part.

Board and sensor

  • ESP32-C3-Zero

    Runs the flight control and creates the Wi-Fi network. Waveshare or another board with the same pinout.

    The AliExpress listing also sells the S3-Zero, which won't work here. Pick the C3-Zero option.

    1×
  • MPU6050

    GY-521 module. Measures tilt and rotation. Some modules sold under this name carry another chip from the same family; the firmware recognizes the most common ones.

    1×

Motors and propellers

  • Kit with 4 brushed 716 motors, 3.7 V, and 4 propellers

    One kit is enough: it comes with the motors and the propellers. Check the propeller size: this tutorial uses 55 mm, 2 CW and 2 CCW.

    1×

Battery and charging

  • LiPo battery, 1S, 3.7 V, 1000 mAh

    I used a 102050. Check the discharge rate (C), not just the capacity: the four motors together can draw more than 4 A, so a 1000 mAh battery needs at least 4C.

    Alternatives: another single-cell (1S) LiPo with similar capacity and enough discharge. Old drones and toys often have one.

    Don't use a swollen or dented battery, or one below 3 V.

    1×
  • TP4056 charger module with protection

    Charges the battery through the ESP32's USB and powers the ESP32 in flight. The module's USB-C connector is removed. On AliExpress, pick the quantity: one unit is enough.

    These modules usually charge at about 1 A, or 1C on this 1000 mAh battery. With a smaller battery, check its charge limit. Don't leave it charging unattended, and don't wire the motors to the OUT pins: the protection can cut the power mid-flight.

    1×
  • 1N5817 Schottky diode

    Connects the TP4056's OUT+ to the ESP32's 5V pin. Keeps the 5 V from USB from flowing straight back into the battery.

    Alternatives: a Schottky rated 1 A or more, such as 1N5819 or SS14.

    1×
  • SS12D10 slide switch

    Sits between the TP4056's OUT+ and the 1N5817. Turns the ESP32 on and off when USB is unplugged.

    Alternatives: any small switch rated 500 mA or more.

    1×

Motor circuit

One set per motor.

  • 9T16GH N-channel MOSFET

    Switches the motor on and off with the GPIO's 3.3 V.

    Alternatives: an N-channel MOSFET that fully turns on with 3.3 V on the Gate, rated 20 V or more and 2.5 A or more, such as AO3400A, SI2302, IRLML2502 or IRLML6344. PC motherboards often have parts like these.

    IRF520, IRFZ44 and other common MOSFETs won't work: they need much more than the GPIO's 3.3 V on the Gate.

    4×
  • FR102 fast diode (1 A, 100 V)

    Absorbs the voltage spike the motor creates when it switches off.

    Alternatives: a fast or Schottky diode rated 1 A or more and 20 V or more, such as SS34, SS24, 1N5819 or 1N5822. A regular diode like the 1N4007 is too slow for this job.

    4×
  • 1 kΩ resistor

    Between the GPIO and the Gate; limits the current.

    Alternatives: 100 Ω to 1 kΩ.

    On AliExpress, the listing is the same as for the 10 kΩ resistor: pick the 1 kΩ value when you buy.

    4×
  • 10 kΩ resistor

    Between the Gate and the Source; keeps the motor off while the ESP32 boots.

    Alternatives: 10 kΩ to 47 kΩ.

    On AliExpress, the listing is the same as for the 1 kΩ resistor: pick the 10 kΩ value when you buy.

    4×
  • 100 nF ceramic capacitor

    Marked 104. Goes between the Drain and B−. It has no polarity.

    Alternatives: ceramic, 47 nF to 220 nF.

    4×

Recommended for flying

You can bench-test without it. In flight, it makes a difference.

  • 470 µF low-ESR electrolytic capacitor

    Not shown in the diagram. Wired between B+ and B−, close to the MOSFETs, it reduces the voltage drop when the motors speed up.

    Alternatives: 330 µF to 1000 µF, rated 6.3 V or more. PC motherboards and power supplies often have low-ESR capacitors.

    1×

You'll also need a soldering iron, a multimeter with a continuity test, a USB-C cable and wire. The frame has to be light and stiff, X-shaped, with the four motors aligned.

Wiring diagram

This is the complete wiring drawing. The steps below go through each part, and the circuit marked 4X repeats for each motor.

Wiring diagram with the ESP32-C3-Zero, the MPU6050, the TP4056 with its USB-C connector removed, the 1000 mAh battery, the switch, the 1N5817 diode and each motor circuit. M1 on GPIO3, M2 on GPIO2, M3 on GPIO20 and M4 on GPIO4. SDA on GPIO6 and SCL on GPIO7.
Open the diagram at full size

Step 1

Build each motor channel

Each motor has its own circuit, repeated four times. The ESP32 only drives the MOSFET Gate; the motor current comes straight from the battery. Never connect a motor directly to a GPIO.

BATTERY +M+−MotorFR102stripe to +100nFDSG9T16GHGPIO1kΩ10kΩBATTERY −TP4056 B−
One channel. All four are the same; only the GPIO changes: 3, 2, 20 and 4.
  • Motor: + terminal to battery positive, − terminal to the Drain.
  • 9T16GH: Source to battery negative, at the TP4056 B−. All four Sources share this point.
  • Gate: 1 kΩ resistor to the GPIO and 10 kΩ resistor to the Source.
  • FR102: striped end to the motor +, plain end to the Drain.
  • 100 nF: between the Drain and B−.

Danger

A reversed FR102 is practically a short circuit as soon as the motor turns on. Check all four stripes before connecting the battery.

On the 9T16GH, with the text facing up and the legs pointing down, the order is Gate, Drain, Source. With another MOSFET, check the datasheet before soldering: don't go by the package shape alone.

Step 2

Place the motors and propellers

The reference is the ESP32's USB connector: it points to the rear. Matching propellers always sit on the diagonal.

FRONTESP32-C3+ MPU6050M1GPIO3Prop AclockwiseM2GPIO2Prop Bcounter-clockwiseM3GPIO20Prop Bcounter-clockwiseM4GPIO4Prop AclockwiseREAR · USB
Top view. Blue spins clockwise; amber, counter-clockwise.
Position, rotation, propeller and GPIO of each motor
MotorPositionRotationPropGPIO
M1Front leftClockwiseA3
M2Front rightCounter-clockwiseB2
M3Rear leftCounter-clockwiseB20
M4Rear rightClockwiseA4
  • If a motor spins the wrong way, swap its two wires.
  • The A and B letters vary from brand to brand. What matters is the blade pitch: every propeller has to push air down.
  • Leave the propellers off for now. They only go on in step 8.

Step 3

Wire the ESP32 and the MPU6050

ESP32-C3-Zero connections
ESP32-C3-ZeroConnects to
GPIO31 kΩ → M1 Gate
GPIO21 kΩ → M2 Gate
GPIO201 kΩ → M3 Gate
GPIO41 kΩ → M4 Gate
GPIO6MPU6050 SDA
GPIO7MPU6050 SCL
3V3MPU6050 VCC
5VTP4056 IN+ and, through the 1N5817, TP4056 OUT+
GNDMPU6050 GND and AD0, TP4056 OUT− and IN−
  • GPIO2 also takes part in the ESP32-C3 boot, so its 10 kΩ resistor is required.
  • GPIO20 is the UART RX. To flash and read logs, use the board's USB.
  • Mount the MPU with the chip facing up and the row of pins facing forward. The firmware expects this orientation.
  • Stick the MPU down with firm foam tape, near the center and away from the motors. Mine sat on the nose, and the vibration distorted the readings in flight.

Step 4

Set up the power

The ESP32's USB does both jobs: when it's plugged in, it powers the ESP32 and charges the battery through the TP4056. Without it, the battery powers the ESP32 through the 1N5817. That's why you remove the TP4056's USB-C connector before wiring it.

Power connections
FromTo
Battery +TP4056 B+ and the + of all four motors
Battery −TP4056 B− and the MOSFET Sources
ESP32 5V pinTP4056 IN+
TP4056 OUT+Switch, then the 1N5817 to the ESP32 5V pin, with the stripe on the ESP32 side
ESP32 GNDTP4056 OUT− and IN−

Danger

Without the 1N5817, or with it reversed, the 5 V from USB goes straight into the battery. Check the stripe before plugging in USB. And never connect the battery to the 3V3 pin: fully charged it reaches 4.2 V, and the ESP32-C3 runs between 3.0 V and 3.6 V.

The diode drops about 0.3 V, and the 5V pin is specified from 3.7 V, so charge the battery before flying. The motors run straight from the battery, and the module doesn't protect it from over-discharge: land when the power starts to fade. Use short, thick wires from the battery to the MOSFETs.

The switch only cuts the battery's power to the ESP32. The motors stay connected to the battery, but they don't spin without a command, and USB charging works with the switch off. To work on the circuit, unplug the battery.

Step 5

Check everything with the multimeter

With the battery unplugged and the multimeter on continuity, confirm that:

  • there's no short between battery + and −;
  • every Source is connected to B−;
  • every FR102 stripe faces battery +;
  • the 1N5817 stripe is on the ESP32 5V pin side;
  • the switch is on the wire coming out of OUT+, before the 1N5817;
  • if you use the 470 µF capacitor, its + and − are the right way round;
  • no Gate is floating or wired straight to the battery.

Step 6

Flash the firmware

Download the firmware (.zip)
  1. In the Arduino IDE, install the esp32 by Espressif Systems package, version 3.x.
  2. In the Library Manager, install ESP Async WebServer 3.12.1 and Async TCP 3.5.0, both by ESP32Async. Watch out for old forks with similar names.
  3. Extract the zip and open DroneFlight/DroneFlight.ino. Config.h, FlightLink.h and build_opt.h must stay in the same folder; Config.h opens as a tab next to the sketch.
  4. In the Config.h tab, section 1, change the drone network password in AP_PASSWORD, with at least 8 characters. The network ships as Drone-C3-Voo with the password drone123, which is printed in this tutorial, so anyone can know it.
  5. Select an ESP32-C3 board, enable USB CDC On Boot and pick the USB port.
  6. Upload. If it doesn't start, hold BOOT, press RESET and release BOOT.
  7. Keep the drone level and still when it powers up: the initial calibration takes about 4 seconds.

Everything you can tune lives in Config.h, with a comment explaining each value: network, pins, safety limits, control gains and the sensor. You don't need to touch DroneFlight.ino. If a value doesn't add up, like fewer than four motor pins, the sketch refuses to compile and says why.

The firmware in the zip ships with PRE_FLIGHT_MODE = true, which limits the throttle to 25% and each motor to 35%. Keep this lock on until step 8.

Step 7

Test without propellers

This test uses the flight firmware itself, still with the pre-flight lock on.

The control page is in Portuguese. These are the labels you will use:

Control page labels and what they mean
On screenMeaning
SOCKET AO VIVOLive connection with the drone
ARMARArm
PARAR E DESARMARStop and disarm (emergency stop)
CALIBRAR NÍVELCalibrate level
AceleraçãoThrottle
DireçãoDirection stick (pitch and roll)
Girar à esquerda / à direitaYaw left / right
Giro ZYaw rate
Máximo dos motoresMotor output limit
M1–M4Fine-tuning screen: per-motor trim and level trim
ZERAR TRIM / ZERAR TUDOReset trim / Reset everything
Tela cheiaFull screen
  1. Connect your phone to the Drone-C3-Voo network, with the password you set, and open http://192.168.4.1. Hold the phone sideways and wait for SOCKET AO VIVO.
  2. Tilt the drone and check the signs: nose down gives a negative Pitch, right side down gives a positive Roll, and turning it clockwise, seen from above, gives a positive Giro Z.
  3. Tap ARMAR, set the throttle to 15–20% and move the drone by hand, checking the table below.
  4. Finish with PARAR E DESARMAR, always before touching the circuit.
Expected motor reaction
MovementMotors that should speed up
Lower the right sideM2 and M4
Lower the left sideM1 and M3
Lower the noseM1 and M2
Lower the tailM3 and M4
Turn clockwiseM1 and M4
Turn counter-clockwiseM2 and M3

Only move on if the motors react as in the table and the battery and MOSFETs stay cool. If a motor doesn't react, check its channel from step 1: the Gate resistor and solder joint, the MOSFET and the diode.

To follow a test with the drone plugged into the computer, open the Arduino IDE Serial Monitor at 115200: every second it shows the attitude, the motors, the commands received and the reason for any disarm.

Step 8

First flight

Danger

Fly in an open, protected area, away from people and animals, and check the local drone rules. A spinning propeller hurts. Only touch the drone after PARAR E DESARMAR.
  1. In Config.h, set PRE_FLIGHT_MODE to false and flash again. Set it back to true whenever you change motors, propellers, pins or the MPU position.
  2. Charge the battery and fit the propellers: M1 and M4 clockwise, M2 and M3 counter-clockwise.
  3. Unplug USB, keep the drone level and still, turn on the switch, connect the phone and set Máximo dos motores to 70%.
  4. Arm and raise the throttle until the drone gets light. Take off decisively, to 20 or 30 cm: scraping along the ground confuses the controller.
  5. Let go of the stick and watch for 5 to 10 seconds. A slow drift is normal: the MPU keeps the drone level, but it doesn't measure position.
  6. Land by bringing the throttle all the way down. If it tilts or oscillates hard, tap PARAR E DESARMAR.

After at least 2 seconds in the air, when you land by lowering the throttle, the firmware learns the drone's imbalance (center of mass off the middle, a weaker motor) and saves it to memory. The next flight starts already compensated, even after a power cycle. Stopping with the button mid-flight doesn't save it.

Fine-tuning on the M1–M4 screen

Tap M1–M4 at the top of the page to open the adjustments. Throttle, direction, ARMAR and the stop button keep working.

The M1–M4 screen of the control page, with plus and minus buttons for each motor, front/back and left/right trim, ZERAR TRIM and ZERAR TUDO
The M1–M4 screen: per-motor adjustment, trim and the reset buttons.
  • Trim: if the drone drifts to one side on its own, correct it gradually, 0.5° per tap, up to 4°. Drifting forward, ▼; backward, ▲; right, ◀︎; left, ▶︎.
  • M1 to M4: add or remove power on a single motor, 0.5% per tap, up to ±5%. Adjust in pairs: if the tail lifts first and the nose moves forward, +0.5% on M1 and M2; right side low, M2 and M4; left side low, M1 and M3.
  • ZERAR TRIM clears the trim, and ZERAR TUDO clears the trim and the motors. The adjustments are saved in the phone's browser: on another phone, tune again.

Fine-tuning makes up for small differences. It won't fix a reversed propeller, a misaligned motor or heavy vibration.

The firmware also cuts the motors on its own in two cases: 3 seconds without commands from the phone, or a tilt above 45° for 100 ms (above 70°, immediately). The control gains were tuned for my drone, so yours may need different values.

Common problems

Symptoms and what to check
SymptomWhat to check
The page shows MPU OFFCheck VCC on 3V3, GND, SDA on GPIO6, SCL on GPIO7 and AD0 on GND. Then restart the board.
The MPU only comes back when I move the droneA bad solder joint or loose wire on VCC, GND, SDA or SCL.
Always drifts the same wayCalibrate on a level surface, center the battery and use the trim on the M1–M4 screen, 0.5° per tap.
Turns the same way on takeoffPropeller direction and motor positions. Redo the reaction table from step 7.
One motor always works harder than the others (see M1 to M4 on the page)A weak propeller or motor in that corner. The compensation eats into the power headroom.
Wobbles slowly, about once per secondRaise RATE_P and RATE_D by 30%. They are in Config.h, section 4.
Fast shaking or buzzingLower RATE_P and RATE_D by 20%.

To truly hold its position, the drone still needs to measure its own movement, with optical flow and distance to the ground. That's the natural next step for this project. I share the progress on TikTok.