Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP32-Controlled Quadcopter with GPS, MPU-6050, and ESP32-CAM

View and Edit Project In Cirkit DesignerImage of ESP32-Controlled Quadcopter with GPS, MPU-6050, and ESP32-CAM

Circuit Documentation

Summary

The circuit in question appears to be designed for a drone or a similar remote-controlled vehicle. It includes brushless motors controlled by electronic speed controllers (ESCs), a power distribution board (PDB) with an XT60 connector, a Lipo battery, and a buck converter for voltage regulation. The circuit also features an MPU-6050 sensor for motion tracking, an HC-SR04 ultrasonic sensor for distance measurement, a GPS module for positioning, and two ESP32 microcontrollers for overall control and communication. Additionally, there is an ESP32-CAM module for capturing images and a flight controller for managing the vehicle's stability. The circuit is completed with a remote receiver for user input.

Component List

Brushless Motor

Electronic Speed Controller (ESC)

MPU-6050

HC-SR04 Ultrasonic Sensor

PDB XT60

Lipo Battery

LM2956 Buck Converter DC-DC

GPS NEO 6M

ESP32 38 PINS

ESP32 - CAM

Resistor

KK 2.1.5 FLIGHT CONTROLLER

FLYSKY FS- IA6

Wiring Details

Brushless Motor

Electronic Speed Controller (ESC)

MPU-6050

HC-SR04 Ultrasonic Sensor

PDB XT60

LM2956 Buck Converter DC-DC

GPS NEO 6M

ESP32 38 PINS

ESP32 - CAM

Resistor

KK 2.1.5 FLIGHT CONTROLLER

FLYSKY FS- IA6

Documented Code

ESP32 38 PINS Microcontroller (Main Controller)

// Development of Drone Surveillance Technology Using ESP32
// This code interfaces with an ESP32, MPU-6050, HC-SR04, GPS NEO 6M, and ESP32-CAM.
// The ESP32 reads data from the MPU-6050 (IMU), HC-SR04 (Ultrasonic Sensor), and GPS.
// It also controls the ESCs for the brushless motors and captures images using the ESP32-CAM.

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

// Pin Definitions
#define MPU6050_SDA 21
#define MPU6050_SCL 22
#define ULTRASONIC_TRIG 12
#define ULTRASONIC_ECHO 13
#define ESC1_SIGNAL 23
#define ESC2_SIGNAL 19
#define ESC3_SIGNAL 18
#define ESC4_SIGNAL 17

// MPU6050
Adafruit_MPU6050 mpu;

// Ultrasonic Sensor
long duration;
int distance;

// Servo objects for ESCs
Servo esc1;
Servo esc2;
Servo esc3;
Servo esc4;

void setup() {
  Serial.begin(115200);
  Wire.begin(MPU6050_SDA, MPU6050_SCL);

  // Initialize MPU6050
  if (!mpu.begin()) {
    Serial.println("Failed to find MPU6050 chip");
    while (1) {
      delay(10);
    }
  }
  mpu.setAccelerometerRange(MPU6050_RANGE_8_G);
  mpu.setGyroRange(MPU6050_RANGE_500_DEG);
  mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);

  // Initialize Ultrasonic Sensor
  pinMode(ULTRASONIC_TRIG, OUTPUT);
  pinMode(ULTRASONIC_ECHO, INPUT);

  // Attach ESCs to pins
  esc1.attach(ESC1_SIGNAL);
  esc2.attach(ESC2_SIGNAL);
  esc3.attach(ESC3_SIGNAL);
  esc4.attach(ESC4_SIGNAL);

  // Initialize WiFi
  WiFi.begin("yourSSID", "yourPASSWORD");
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }
  Serial.println("Connected to WiFi");
}

void loop() {
  // Read MPU6050 data
  sensors_event_t a, g, temp;
  mpu.getEvent(&a, &g, &temp);
  Serial.print("AccelX: "); Serial.print(a.acceleration.x);
  Serial.print(", AccelY: "); Serial.print(a.acceleration.y);
  Serial.print(", AccelZ: "); Serial.println(a.acceleration.z);

  // Read Ultrasonic Sensor data
  digitalWrite(ULTRASONIC_TRIG, LOW);
  delayMicroseconds(2);
  digitalWrite(ULTRASONIC_TRIG, HIGH);
  delayMicroseconds(10);
  digitalWrite(ULTRASONIC_TRIG, LOW);
  duration = pulseIn(ULTR