null
Find a file
2025-09-13 11:02:43 +03:30
controller-client.py Add controller-client script for keyboard to serial control and implement manual control sketches for MPU6050-based quadcopter. Update README for wiring clarification. 2025-09-13 11:02:43 +03:30
README.md Add controller-client script for keyboard to serial control and implement manual control sketches for MPU6050-based quadcopter. Update README for wiring clarification. 2025-09-13 11:02:43 +03:30
skecth-manual-control-mpu.ino Add controller-client script for keyboard to serial control and implement manual control sketches for MPU6050-based quadcopter. Update README for wiring clarification. 2025-09-13 11:02:43 +03:30
skecth-manual-control.ino Add controller-client script for keyboard to serial control and implement manual control sketches for MPU6050-based quadcopter. Update README for wiring clarification. 2025-09-13 11:02:43 +03:30
sketch-bt-oled-1.ino Initial implementation of Bluetooth and OLED display functionality in three separate sketches. Each sketch includes setup for Bluetooth communication and display updates based on received messages. 2025-09-11 23:20:28 +03:30
sketch-bt-oled-2.ino Initial implementation of Bluetooth and OLED display functionality in three separate sketches. Each sketch includes setup for Bluetooth communication and display updates based on received messages. 2025-09-11 23:20:28 +03:30
sketch-bt.ino Initial implementation of Bluetooth and OLED display functionality in three separate sketches. Each sketch includes setup for Bluetooth communication and display updates based on received messages. 2025-09-11 23:20:28 +03:30
sketch-http-server.ino Add README for DIY Quadcopter project and implement HTTP server for motor control 2025-09-11 23:20:54 +03:30
sketch-single-motor.ino Add controller-client script for keyboard to serial control and implement manual control sketches for MPU6050-based quadcopter. Update README for wiring clarification. 2025-09-13 11:02:43 +03:30

DIY Quadcopter Build with ESP32, MPU6050, Battery, LittleBee BLHeli-S ESC, and 2-Wire Brushless Motors

Overview

Important Update: Based on your latest specification, we're using brushless motors with 2 wires. This is an uncommon configuration for standard brushless motors (which typically have 3 wires for the stator phases). After research, this likely refers to a sensorless brushless DC (BLDC) motor with integrated ESC (common in small, cheap toy drones like Eachine E010 or Hubsan H107 variants). These "2-wire" setups use the two wires for power input (e.g., + and - from battery), with the ESC built into the motor housing handling commutation internally. They behave like a single unit: you apply PWM-modulated voltage to control speed/direction.

This simplifies wiring but limits customization—no separate ESC tuning or 3-phase control. The LittleBee BLHeli-S ESC (designed for 3-wire motors) is not compatible here, as it outputs 3-phase signals. We'll treat the 2-wire motor+ESC as a "PWM speed controller" unit.

Project Goals:

  • Basic quadcopter with stabilization via MPU6050 PID.
  • ESP32 PWM control to the 2-wire motors.
  • Indoor/lightweight flights due to battery limits.
  • Total Cost: ~$70$130 (assuming you have the motors).

Assumptions:

  • 4x 2-wire brushless motors (e.g., 3.7V11.1V, ~12A draw each; examples: 8520 coreless-style BLDC with integrated ESC).
  • Battery: 3S LiPo (11.1V, 1000mAh, 10A total discharge—limits total thrust to ~2.5A/motor; upgrade for better performance).
  • Arduino IDE for programming.
  • No advanced features like DShot (PWM only, 50Hz1kHz).

Limitations:

  • 2-wire BLDC motors are toy-grade: low efficiency, no reverse, fixed direction (mount CW/CCW pairs).
  • Battery 10A total = gentle hover only; risk of sag under load.

Parts List

Component Description Quantity Notes / Recommendations Approx. Cost (USD) Purchase Link Example
ESP32 Dev Module Main microcontroller (WiFi/BT, PWM outputs) 1 ESP32-WROOM-32 $5$10 Amazon
MPU6050 6-axis IMU (gyro + accelerometer) 1 GY-521 module $2$5 Amazon
Battery 3S LiPo (11.1V, 1000mAh, 10C discharge) 1 JST or XT30 connector; 10A total limits power—consider 20C upgrade $10$20 Amazon
LittleBee BLHeli-S ESC 20A brushless ESC (unused in this config) 4 Not used—incompatible with 2-wire motors. Sell/repurpose for 3-wire upgrade. $10$15 each (total $40$60) Banggood
2-Wire Brushless Motors Integrated ESC BLDC motors (2 wires: +/ PWM input) 4 3.7V11.1V, 8520/716 size, CW/CCW pairs; e.g., from mini drone spares $5$10 each Amazon (Mini Drone Motors) or Banggood
Propellers 5565mm plastic (CW/CCW) 4+ spares Match motor shaft; low-pitch for low current $3$5 pack Amazon
Frame 150250mm lightweight (3D-printed or plastic) 1 Suited for mini motors $5$15 Amazon
Power Distribution Simple PDB or direct wiring 1 For battery to motors; use capacitors for smoothing $3$5 Amazon
Charger LiPo balance charger 1 iMAX B6; safety first $20$30 Amazon
Optional: Wires/Connectors JST/Servo cables, capacitors (1000µF) As needed For PWM signal and power smoothing $5 Amazon

Total Estimated Cost: $70$130 (excluding unused ESCs).

Why LittleBee is Unused: It requires 3-wire motors for phase control. 2-wire motors have built-in ESCs, so direct PWM to power wires.


Wiring Diagram

Key Principles

  • Power: Battery → PDB/direct → Motor power wires (+/). Modulate + wire with PWM for speed (or use MOSFET for high-side switching).
  • Signal: ESP32 PWM pins → Motor signal (often the + wire via low-pass filter or direct if motor accepts it).
  • IMU: Standard I2C.
  • Grounds: Common GND essential.
  • 2-Wire Motor Handling: Treat as brushed-like: PWM on one wire (usually red/+ for speed). Motors spin one direction only—flip mount for CCW.
  • Safety: Add 1000µF capacitor across motor +/ to reduce noise. Test at low voltage.

Text-Based ASCII Diagram (Full Quad Setup)

+-------------------+          +-------------------+
|     Battery 3S    |          |     PDB / Wires   |
|   (11.1V, JST)    |----------|   (Power Split)   |
+-------------------+          +-------------------+
                                   | | | |  (+/ to each motor power)
                                   v v v v
                  +-------------------+
                  | 2-Wire Motor #1   |  (Red: PWM + Power, Black: GND)
                  | PWM: GPIO2 (via   |
                  |      MOSFET opt.) |
                  +-------------------+
                  | 2-Wire Motor #2   |
                  | PWM: GPIO4        |
                  +-------------------+
                  | 2-Wire Motor #3   |
                  | PWM: GPIO5        |
                  +-------------------+
                  | 2-Wire Motor #4   |
                  | PWM: GPIO18       |
                  +-------------------+

+-------------------+          +-------------------+
|     ESP32         |          |     MPU6050       |
|                   |          |                   |
| 5V (USB/BEC) -----|----------| VCC (3.3V)        |
| GND  -------------|----------| GND               |
| GPIO21 (SDA) -----|----------| SDA               |
| GPIO22 (SCL) -----|----------| SCL               |
| GPIO 2 (PWM1) ----|----------| (To Motor #1 Red) |
| GPIO 4 (PWM2) ----|----------| (To Motor #2 Red) |
| GPIO 5 (PWM3) ----|----------| (To Motor #3 Red) |
| GPIO18 (PWM4) ----|----------| (To Motor #4 Red) |
+-------------------+          +-------------------+
  | (All GNDs common with Battery )

  • PWM Details: 1kHz frequency, 0255 duty cycle (0% = stop, 100% = full). For integrated ESCs, 10002000µs servo PWM if supported.
  • MOSFET Option: If direct GPIO can't handle current, use N-channel MOSFET (e.g., IRLZ44N) per motor: ESP PWM → Gate, Motor + → Drain, Battery + → Source.
  • Visual Resources:

Software/Firmware

Setup

  • Arduino IDE + ESP32 support.
  • Libraries: Adafruit_MPU6050, Adafruit_Sensor, Wire (I2C). Use ledc for PWM (no Servo lib needed for duty cycle).
  • PWM Config: 1000Hz, 8-bit resolution.
  • Arming: Not needed—motors spin on PWM >10%.

Sample Code (IMU Read + PWM Throttle Test)

Remove props! Ramps PWM to motors.

#include <Wire.h>
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>

Adafruit_MPU6050 mpu;

const int motorPins[4] = {2, 4, 5, 18};  // PWM pins to motor red wires
const int freq = 1000;  // 1kHz PWM
const int resolution = 8;  // 0-255 duty
int channels[4];

void setup() {
  Serial.begin(115200);
  Wire.begin(21, 22);  // SDA=21, SCL=22
  if (!mpu.begin()) {
    Serial.println("MPU6050 not found!");
    while (1) delay(10);
  }
  Serial.println("MPU6050 Ready!");

  // Setup PWM channels
  for (int i = 0; i < 4; i++) {
    channels[i] = i;
    ledcSetup(channels[i], freq, resolution);
    ledcAttachPin(motorPins[i], channels[i]);
    ledcWrite(channels[i], 0);  // Stop
  }
}

void setMotorSpeed(int idx, int duty) {  // 0-255
  if (idx < 0 || idx > 3) return;
  duty = constrain(duty, 0, 255);
  ledcWrite(channels[idx], duty);
}

void loop() {
  // Read MPU6050
  sensors_event_t a, g, temp;
  mpu.getEvent(&a, &g, &temp);
  Serial.print("Accel X: "); Serial.print(a.acceleration.x);
  Serial.print(" Y: "); Serial.print(a.acceleration.y);
  Serial.print(" Z: "); Serial.println(a.acceleration.z);

  // Test: Ramp to 50% duty (128/255)
  int testDuty = 128;
  for (int i = 0; i < 4; i++) {
    setMotorSpeed(i, testDuty);
  }
  delay(2000);

  // Stop
  for (int i = 0; i < 4; i++) {
    setMotorSpeed(i, 0);
  }
  delay(3000);
}
  • PID Integration: Add PID library; adjust duties based on roll/pitch from MPU angles.
  • Direction: Fixed—no reverse. Ensure 2 CW/2 CCW motors.

Resources

Build Steps

  1. Frame & Motors: Mount motors (2 CW front/rear-left, 2 CCW others).
  2. Wiring: Battery → Motors (+/); ESP PWM → Motor red wires; MPU I2C.
  3. Program: Flash code; test PWM ramp (no props).
  4. Tune: Calibrate MPU; add PID for stability.
  5. Fly: Indoor hover tests; monitor battery voltage.

Tips & Safety

  • Battery: 10A limit = ~30s flights; use low duty (<50%) to avoid sag.
  • Unused ESCs: Consider returning/selling LittleBee for 3-wire upgrade.
  • Troubleshooting: No spin? Check PWM duty >20; verify voltage. Vibration? Add foam dampers.
  • Safety: Props off for tests; charge LiPos safely; wear goggles.
  • Upgrades: For true brushless, switch to 3-wire motors + LittleBee.