Circuit Documentation
Summary
The circuit in question appears to be designed for a quadcopter or similar multirotor UAV (Unmanned Aerial Vehicle). It includes four brushless motors, each controlled by an individual Electronic Speed Controller (ESC). The power distribution is managed by a PDB XT60, which distributes power from a Lipo Battery to the ESCs. The circuit also includes an MPU-6050 sensor for motion tracking, an ESP32 microcontroller for general control, and an ESP32-CAM module for capturing images or video.
Component List
Brushless Motor
- Description: A type of motor that is commonly used in drones for its high power-to-weight ratio and efficiency.
- Pins: L1, L2, L3
Electronic Speed Controller (ESC)
- Description: An electronic circuit that controls the speed of an electric motor. It also provides a 5V output that can be used to power other components.
- Pins: Battery VCC, Battery GND, Signal, 5v out, GND out, M1, M2, M3
MPU-6050
- Description: A motion tracking device that contains a 3-axis gyroscope and a 3-axis accelerometer.
- Pins: VCC, GND, SCL, SDA, XDA, XCL, AD0, INT
PDB XT60
- Description: A power distribution board that simplifies the wiring of power and ground to multiple components.
- Pins: +, -, GND, VCC, 5V, 12V
Lipo Battery
- Description: A rechargeable battery of lithium-ion technology used for high energy storage.
- Pins: VCC, GND
ESP32 38 PINS
- Description: A microcontroller with Wi-Fi and Bluetooth capabilities, suitable for a variety of applications including drone control.
- Pins: GND, G23, G22, TXD, RXD, G21, G19, G18, G5, G17, G16, G4, G0, G2, G15, SDI, SD0, CLK, 3V3, EN, SP, SN, G34, G35, G32, 33, G25, G26, G27, G14, G12, G13, SD2, SD3, 5V
ESP32 - CAM
- Description: A small-sized camera module that can be used for surveillance or capturing images from a UAV.
- Pins: 5V, GND, IO12, IO13, IO15, IO14, IO2, IO4, VOT, VOR, VCC, IO0, IO16, 3V3
Wiring Details
Brushless Motors
- Motor 1
- L1, L2, L3 connected to ESC M1, M2, M3 respectively.
- Motor 2
- L1, L2, L3 connected to ESC M1, M2, M3 respectively.
- Motor 3
- L1, L2, L3 connected to ESC M1, M2, M3 respectively.
- Motor 4
- L1, L2, L3 connected to ESC M1, M2, M3 respectively.
Electronic Speed Controllers (ESCs)
- All ESCs have their Battery VCC and Battery GND connected to the PDB XT60's + and - respectively.
- ESC Signal pins are connected to the ESP32 pins G21, G23, G18, and G19 for motor control.
MPU-6050
- VCC connected to ESP32 3V3.
- GND connected to ESP32 GND.
- SCL connected to ESP32 G2.
- SDA connected to ESP32 G21.
PDB XT60
-
- and - distribute power to all ESCs.
- VCC and GND are not detailed in the net list.
Lipo Battery
- VCC and GND connected to PDB XT60 + and - respectively.
ESP32 38 PINS
- GND connected to GND out on all ESCs.
- G21, G23, G18, G19 connected to Signal on ESCs for motor control.
- 3V3 connected to MPU-6050 VCC.
ESP32 - CAM
- 5V connected to ESP32 3V3.
- GND connected to ESP32 GND.
Documented Code
ESP32 38 PINS (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(ULTRASONIC_ECHO, HIGH);
distance = duration * 0.034 / 2;
Serial.print("Distance: "); Serial.print(distance);
Serial.println(" cm");
// Control ESCs (example: set to 1000us pulse width)
esc1.writeMicroseconds(1000);
esc2.writeMicroseconds(1000);
esc3.writeMicroseconds(1000);
esc4.writeMicroseconds(1000);
delay(1000);
}
ESP32 - CAM (Camera Module)
/*
* Development of Drone Surveillance Technology Using ESP32-CAM
* This code interfaces with an ESP32-CAM and an HC-SR04 Ultrasonic Sensor.
* The ESP32-CAM captures images when motion is detected by the HC-SR04.
*/
#include "esp_camera.h"
#include <WiFi.h>
// Pin Definitions
#define ULTRASONIC_TRIG 12
#define ULTRASONIC_ECHO 13
// Camera configuration
#define PWDN_GPIO_NUM -1
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 0
#define SIOD_GPIO_NUM 26
#define SIOC_GPIO_NUM 27
#define Y9_GPIO_NUM 35
#define Y8_GPIO_NUM 34
#define Y7_GPIO_NUM 39
#define Y6_GPIO_NUM 36
#define Y5_GPIO_NUM 21
#define Y4_GPIO_NUM 19
#define Y3_GPIO_NUM 18
#define Y2_GPIO_NUM 5
#define VSYNC_GPIO_NUM 25
#define HREF_GPIO_NUM 23
#define PCLK_GPIO_NUM 22
// WiFi credentials
const char* ssid = "yourSSID";
const char* password =
