In recent years, the rapid advancement of information technology, sensor technology, and micro-electromechanical systems (MEMS) has propelled unmanned aerial vehicles (UAVs) to the forefront of research and development. Among various UAV types, multi-rotor drones, particularly quadrotor drones, have gained significant attention due to their structural simplicity, excellent maneuverability, and high reliability. A quadrotor drone is an underactuated, strongly coupled nonlinear system that achieves flight through the differential thrust generated by four rotors. Its applications span numerous fields, including aerial photography, environmental monitoring, disaster rescue, infrastructure inspection, and cargo delivery. This article presents the design and implementation of a small-scale quadrotor drone utilizing an STM32 microcontroller and an MPU6050 six-axis motion processing sensor. The focus is on the flight control system, which enables stable hovering and responsive control via a smartphone app over Wi-Fi communication.
The quadrotor drone market has expanded dramatically, driven by the need for cost-effective and versatile aerial platforms. Unlike fixed-wing UAVs that require runways or helicopters with complex mechanics, quadrotor drones offer vertical take-off and landing (VTOL) capabilities and can hover precisely, making them ideal for confined spaces. The design challenges include achieving stable flight despite inherent instabilities, minimizing weight and power consumption, and ensuring robust communication. This project addresses these challenges by leveraging a lightweight frame, efficient brushless motors, and a sophisticated control algorithm implemented on a low-power STM32 microcontroller. The integration of an MPU6050 sensor provides real-time attitude data, while a Wi-Fi module facilitates remote control without dedicated hardware. The result is a compact, affordable, and highly maneuverable quadrotor drone suitable for educational and hobbyist purposes.

Quadrotor drones can be classified based on the arrangement of rotors relative to the flight direction. The two primary configurations are the plus-type (or cross-type) and the X-type. In a plus-type quadrotor drone, one rotor aligns directly with the front of the drone, simplifying control logic as each axis primarily involves a single motor. However, this configuration may limit agility. In contrast, an X-type quadrotor drone has the front direction bisecting two rotors, allowing for more rapid and flexible maneuvers since attitude adjustments typically engage multiple motors simultaneously. This makes X-type quadrotor drones preferable for acrobatic flights and extended functionality. Therefore, this design adopts the X-type configuration to enhance responsiveness and control precision. The overall system comprises the drone itself and a remote control unit. Instead of a traditional radio controller, a smartphone app communicates with the drone via Wi-Fi, leveraging the widespread availability of Wi-Fi networks for greater convenience and range compared to Bluetooth. The development encompasses both the mobile app software and the drone’s hardware and firmware, with emphasis on the flight control system.
| Configuration | Advantages | Disadvantages | Typical Use Cases |
|---|---|---|---|
| Plus-Type (Cross-Type) | Simpler control, clear front orientation | Less agile, slower response | Basic flight training, stable hovering |
| X-Type | High agility, faster maneuverability | More complex control algorithms | Acrobatic flights, advanced applications |
The hardware architecture of the quadrotor drone is centered around the STM32F103C8 microcontroller, a 32-bit ARM Cortex-M3 processor operating at 72 MHz. This microcontroller provides sufficient computational power for real-time attitude estimation and control while maintaining low power consumption. Key peripherals include multiple I²C, SPI, and UART interfaces, as well as timers capable of generating pulse-width modulation (PWM) signals for motor control. The core components are listed below:
- STM32F103C8 Microcontroller: Serves as the flight control unit, processing sensor data and executing control algorithms.
- MPU6050 Six-Axis Sensor: Combines a 3-axis gyroscope and a 3-axis accelerometer to measure angular rates and linear accelerations.
- ATK-ESP8266 Wi-Fi Module: Enables wireless communication with a smartphone app for receiving control commands.
- 720-Size Coreless Brushed Motors: Four lightweight motors paired with 55mm propellers to generate thrust.
- Lithium Polymer Battery and Power Management Module: Supplies stable voltage to all components and manages charging.
The MPU6050 sensor is crucial for attitude sensing. It communicates with the microcontroller via the I²C protocol, providing raw data that must be fused to estimate orientation. The gyroscope measures angular velocity around the roll, pitch, and yaw axes, which can be integrated to obtain angles, but this leads to drift over time. The accelerometer measures proper acceleration, which can be used to compute tilt angles relative to gravity, though it is sensitive to vibrations. By combining both sensors through sensor fusion algorithms like complementary filters or Kalman filters, accurate and stable attitude estimates are achieved. The quadrotor drone’s dynamics involve six degrees of freedom: translational motion along the x, y, and z axes, and rotational motion around these axes. The equations of motion are derived from Newton-Euler principles. For a quadrotor drone, the thrust generated by each motor is proportional to the square of its rotational speed. Let $F_i$ denote the thrust from motor $i$, and $\omega_i$ its angular speed. Then:
$$F_i = k_f \omega_i^2$$
where $k_f$ is the thrust coefficient. The total thrust $T$ is the sum of individual thrusts:
$$T = \sum_{i=1}^{4} F_i = k_f (\omega_1^2 + \omega_2^2 + \omega_3^2 + \omega_4^2)$$
The moments around the roll ($\phi$), pitch ($\theta$), and yaw ($\psi$) axes are given by:
$$\tau_\phi = l k_f (-\omega_1^2 + \omega_2^2 + \omega_3^2 – \omega_4^2)$$
$$\tau_\theta = l k_f (\omega_1^2 + \omega_2^2 – \omega_3^2 – \omega_4^2)$$
$$\tau_\psi = k_m (\omega_1^2 – \omega_2^2 + \omega_3^2 – \omega_4^2)$$
where $l$ is the arm length from the center to each motor, and $k_m$ is the drag coefficient. The rotational dynamics can be expressed as:
$$I \dot{\omega} + \omega \times (I \omega) = \tau$$
where $I$ is the inertia matrix, $\omega$ is the angular velocity vector, and $\tau$ is the torque vector. For small angles, the linearized equations simplify control design. The translational dynamics depend on the orientation and thrust:
$$m \ddot{x} = -T \sin\theta$$
$$m \ddot{y} = T \cos\theta \sin\phi$$
$$m \ddot{z} = T \cos\theta \cos\phi – mg$$
where $m$ is the mass, $g$ is gravity, and $x, y, z$ are positions. These equations highlight the underactuated nature of the quadrotor drone: while there are six degrees of freedom, only four control inputs (motor speeds) are available, necessitating coupled control strategies.
| Component | Model/Specification | Key Parameters |
|---|---|---|
| Microcontroller | STM32F103C8 | 72 MHz CPU, 64 KB Flash, 20 KB RAM, multiple timers |
| Motion Sensor | MPU6050 | ±2000°/s gyro, ±16g accelerometer, I²C interface |
| Wi-Fi Module | ATK-ESP8266 | 802.11 b/g/n, UART interface, up to 100m range |
| Motors | 720 Coreless Brushed | 7mm diameter, 20,000 RPM, 3.7V operating voltage |
| Propellers | 55mm Two-Blade | Plastic, designed for thrust efficiency |
| Battery | Lithium Polymer | 3.7V, 600mAh, providing ~8 minutes flight time |
The software design for the quadrotor drone is implemented in bare-metal programming on the STM32 microcontroller, ensuring low latency and deterministic execution. The firmware consists of several modules: serial communication, PWM generation, I²C driver for the MPU6050, PID control algorithms, and the main flight control loop. All modules are written in C and optimized for real-time performance. The quadrotor drone’s stability relies heavily on the control algorithm, which processes sensor data and remote commands to adjust motor speeds.
The serial communication module utilizes two UART interfaces. USART1 is configured for debugging with a PC, allowing real-time data monitoring via a serial terminal. USART2 connects to the Wi-Fi module, enabling bidirectional communication with the smartphone app. The baud rate is set to 115200 bps for both interfaces. Functions such as USART_ReceiveData, USART_SendData, and USART_OUT handle byte-wise and string transmission. The Wi-Fi module receives commands like throttle, roll, pitch, and yaw setpoints from the app, which are parsed and normalized for the control system. This setup allows the quadrotor drone to be controlled within Wi-Fi range without specialized hardware, enhancing accessibility.
The PWM module generates signals to control motor speeds. The STM32’s timers (e.g., TIM1 and TIM4) are configured in PWM output mode. Each timer channel is mapped to a GPIO pin connected to a motor driver. The PWM frequency is set to 500 Hz, with a resolution of 16 bits, allowing precise speed adjustments. The duty cycle corresponds to the desired thrust. A function Motor_SetPwm takes four arguments (PWM1 to PWM4) and updates the compare registers accordingly. For safety, a dead zone is implemented to prevent motors from spinning at very low signals. The quadrotor drone’s motors are calibrated to ensure uniform response, as imbalances can cause instability.
The core of the flight control system is the PID (Proportional-Integral-Derivative) controller, implemented as a cascade loop for improved performance. A single-loop PID controlling only angles may suffer from overshoot and slow response. Therefore, a cascade structure with an inner angular rate loop and an outer angle loop is adopted. This approach enhances damping and robustness against disturbances. The block diagram illustrates the cascade PID control for the quadrotor drone. The desired angles ($\phi_d, \theta_d, \psi_d$) come from the remote controller. The actual angles ($\phi, \theta, \psi$) are estimated from sensor fusion. The angle error is fed into the angle PID controller, which outputs desired angular rates ($p_d, q_d, r_d$). These are compared with measured rates from the gyroscope, and the rate error is processed by the rate PID controller to produce control signals ($u_\phi, u_\theta, u_\psi$). These signals are then mixed to compute individual motor PWM values.
The PID control law for each axis is given by:
$$u(t) = K_p e(t) + K_i \int_0^t e(\tau) d\tau + K_d \frac{de(t)}{dt}$$
where $e(t)$ is the error signal, and $K_p$, $K_i$, $K_d$ are tuning parameters. In discrete time for microcontroller implementation, the integral and derivative terms are approximated:
$$u_k = K_p e_k + K_i \sum_{j=0}^{k} e_j \Delta t + K_d \frac{e_k – e_{k-1}}{\Delta t}$$
where $\Delta t$ is the sampling period. For the quadrotor drone, separate PID controllers are designed for roll, pitch, and yaw axes. The angle loop runs at 200 Hz (5 ms period), while the rate loop runs at 500 Hz (2 ms period) to ensure timely response. The output of the rate PID is scaled and limited to prevent actuator saturation. The control mixing for an X-type quadrotor drone converts the collective thrust $T_c$ and torque demands into motor commands:
$$\begin{bmatrix} \omega_1^2 \\ \omega_2^2 \\ \omega_3^2 \\ \omega_4^2 \end{bmatrix} = \begin{bmatrix} 1 & -1 & 1 & 1 \\ 1 & 1 & -1 & -1 \\ 1 & 1 & 1 & 1 \\ 1 & -1 & -1 & 1 \end{bmatrix} \begin{bmatrix} T_c \\ u_\phi \\ u_\theta \\ u_\psi \end{bmatrix}$$
This mixing matrix accounts for the rotor layout and ensures that control inputs are properly distributed. The squared angular speeds are then converted to PWM duty cycles via a linear mapping.
| Control Loop | Axis | $K_p$ | $K_i$ | $K_d$ |
|---|---|---|---|---|
| Angle Loop | Roll ($\phi$) | 3.5 | 0.05 | 0.8 |
| Pitch ($\theta$) | 3.5 | 0.05 | 0.8 | |
| Yaw ($\psi$) | 4.0 | 0.02 | 0.5 | |
| Rate Loop | Roll ($p$) | 0.8 | 0.01 | 0.1 |
| Pitch ($q$) | 0.8 | 0.01 | 0.1 | |
| Yaw ($r$) | 1.0 | 0.005 | 0.05 |
The main program flowchart outlines the execution sequence. After system initialization, which includes clock setup, GPIO configuration, peripheral initialization, and sensor calibration, the microcontroller enters an infinite loop. Two interrupt service routines (ISRs) are used for timing-critical tasks: a 2 ms ISR for the rate loop and a 5 ms ISR for the angle loop. In the 2 ms ISR, gyroscope data is read, and the rate PID controllers compute intermediate outputs. In the 5 ms ISR, accelerometer data is fused with gyroscope data using a complementary filter to estimate angles, and the angle PID controllers update the desired rates. The main loop also handles non-critical tasks like reading Wi-Fi commands, monitoring battery voltage, and controlling status LEDs. The complementary filter for attitude estimation is given by:
$$\hat{\theta}_k = \alpha (\hat{\theta}_{k-1} + \omega_{\theta,k} \Delta t) + (1 – \alpha) \theta_{\text{acc},k}$$
where $\hat{\theta}_k$ is the estimated pitch angle, $\omega_{\theta,k}$ is the gyroscope reading, $\theta_{\text{acc},k}$ is the angle from accelerometer, $\Delta t$ is the sampling time, and $\alpha$ is a weighting factor (typically 0.98). Similar equations apply for roll and yaw, though yaw requires integration from gyro only unless a magnetometer is added. This filter effectively reduces noise and drift, providing smooth attitude estimates for the quadrotor drone.
Experiments were conducted to evaluate the quadrotor drone’s performance. The drone was able to take off, hover steadily, and respond to basic commands such as forward/backward, left/right, and yaw rotations. The flight stability was assessed by measuring attitude deviations during hovering. Without control, the quadrotor drone is inherently unstable and would flip over immediately. With the cascade PID control, the maximum angle error was within ±5 degrees under calm indoor conditions. The control response time was less than 0.5 seconds for step inputs. The Wi-Fi range extended up to 50 meters in open areas, though latency increased with distance. Battery life averaged 7-8 minutes per charge, limiting extended operations. These results demonstrate that the designed quadrotor drone meets basic flight requirements, though there is room for improvement in endurance and robustness.
| Metric | Value | Conditions |
|---|---|---|
| Hover Stability (Angle Error) | ±5° | Indoor, no wind |
| Control Response Time | < 0.5 s | Step input of 10° |
| Wi-Fi Range | Up to 50 m | Line-of-sight, open area |
| Flight Time | 7-8 minutes | With 600mAh battery |
| Maximum Payload | 20 grams | Without stability loss |
In conclusion, this project successfully designed and implemented a small quadrotor drone based on an STM32 microcontroller and MPU6050 sensor. The X-type configuration was chosen for agility, and the hardware integrates essential components for flight control and wireless communication. The software employs a cascade PID algorithm to stabilize the quadrotor drone, with sensor fusion providing accurate attitude estimation. The use of Wi-Fi for control eliminates the need for a dedicated remote, making the system more accessible. The quadrotor drone demonstrated stable flight and responsive control, validating the design approach. However, limitations in battery capacity and communication range restrict operational scope. Future work will focus on enhancing the quadrotor drone by incorporating brushless motors for greater efficiency, adding a GPS module for position hold, implementing more advanced control strategies like nonlinear or adaptive control, and increasing battery capacity for longer flights. Additionally, computer vision could be integrated for autonomous navigation. The quadrotor drone platform serves as a foundation for further research and development in unmanned aerial systems.
The design of this quadrotor drone highlights the interplay between hardware selection, software algorithms, and system integration. By leveraging off-the-shelf components and open-source tools, a cost-effective yet capable UAV was built. The insights gained from this project can guide future iterations and contribute to the growing field of small-scale drones. As technology progresses, quadrotor drones will continue to evolve, offering enhanced capabilities for diverse applications. This work underscores the importance of robust flight control in achieving reliable performance, a critical aspect for any quadrotor drone intended for real-world use.
