ESP32-CAM Wi-Fi Controlled Robotic Car with Camera and Motor Control
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to control a Wi-Fi-enabled car using an ESP32-CAM microcontroller. The car is powered by a 3.7V battery and includes multiple DC motors controlled by DRV8833 motor drivers. The ESP32-CAM also streams video over Wi-Fi, allowing for remote control and monitoring. The circuit includes a power regulation module to ensure stable voltage levels and a rocker switch for power control.
Component List
ESP32-CAM
- Description: A microcontroller with built-in Wi-Fi and camera capabilities.
- Pins: 5V, GND, IO12, IO13, IO15, IO14, IO2, IO4, VOT, VOR, VCC, IO0, IO16, 3V3
3.7V Battery
- Description: A rechargeable battery providing power to the circuit.
- Pins: +, -
DC Motor
- Description: A motor used for driving the car.
- Pins: pin 1, pin 2
MP1584EN Power Regulator Board
- Description: A power regulation module to provide stable voltage.
- Pins: IN -, IN +, OUT +, OUT -
Drv8833 Motor Driver
- Description: A motor driver for controlling the DC motors.
- Pins: EEP, OUT1, OUT2, OUT3, OUT4, ULT, IN4, IN3, GND, VCC, IN1, IN2
Rocker Switch
- Description: A switch to control the power supply.
- Pins: output, input
Electrolytic Capacitor (100 Farads)
- Description: A capacitor for smoothing voltage fluctuations.
- Pins: -, +
Electrolytic Capacitor (0.1 Farads)
- Description: A capacitor for smoothing voltage fluctuations.
- Pins: -, +
Resistor (330 Ohms)
- Description: A resistor for current limiting.
- Pins: pin1, pin2
Wiring Details
ESP32-CAM
- 5V connected to OUT + of MP1584EN Power Regulator Board
- GND connected to OUT - of MP1584EN Power Regulator Board
- IO12 connected to IN1 of Drv8833
- IO13 connected to IN1 of another Drv8833
- IO15 connected to IN2 of another Drv8833
- IO14 connected to IN2 of Drv8833
- IO2 connected to IN3 of Drv8833
- IO4 connected to IN4 of Drv8833
3.7V Battery
- + connected to output of Rocker Switch
- - connected to IN - of MP1584EN Power Regulator Board
DC Motor 1
- pin 1 connected to OUT2 of Drv8833
- pin 2 connected to OUT1 of Drv8833
DC Motor 2
- pin 1 connected to OUT2 of another Drv8833
- pin 2 connected to OUT1 of another Drv8833
DC Motor 3
- pin 1 connected to OUT4 of Drv8833
- pin 2 connected to OUT3 of Drv8833
MP1584EN Power Regulator Board
- IN + connected to input of Rocker Switch
- IN - connected to - of 3.7V Battery
- OUT + connected to 5V of ESP32-CAM and + of Electrolytic Capacitor (100 Farads)
- OUT - connected to GND of ESP32-CAM and - of Electrolytic Capacitor (100 Farads)
Drv8833 Motor Driver 1
- IN1 connected to IO12 of ESP32-CAM
- IN2 connected to IO14 of ESP32-CAM
- IN3 connected to IO2 of ESP32-CAM
- IN4 connected to IO4 of ESP32-CAM
- OUT1 connected to pin 2 of DC Motor 1
- OUT2 connected to pin 1 of DC Motor 1
- OUT3 connected to pin 2 of DC Motor 3
- OUT4 connected to pin 1 of DC Motor 3
- VCC connected to OUT + of MP1584EN Power Regulator Board and + of Electrolytic Capacitor (0.1 Farads)
- GND connected to OUT - of MP1584EN Power Regulator Board and - of Electrolytic Capacitor (0.1 Farads)
Drv8833 Motor Driver 2
- IN1 connected to IO13 of ESP32-CAM
- IN2 connected to IO15 of ESP32-CAM
- OUT1 connected to pin 2 of DC Motor 2
- OUT2 connected to pin 1 of DC Motor 2
- VCC connected to OUT + of MP1584EN Power Regulator Board and + of Electrolytic Capacitor (0.1 Farads)
- GND connected to OUT - of MP1584EN Power Regulator Board and - of Electrolytic Capacitor (0.1 Farads)
Rocker Switch
- output connected to + of 3.7V Battery
- input connected to IN + of MP1584EN Power Regulator Board
Electrolytic Capacitor (100 Farads)
- + connected to OUT + of MP1584EN Power Regulator Board
- - connected to OUT - of MP1584EN Power Regulator Board
Electrolytic Capacitor (0.1 Farads)
- + connected to OUT + of MP1584EN Power Regulator Board and VCC of Drv8833
- - connected to OUT - of MP1584EN Power Regulator Board and GND of Drv8833
Resistor (330 Ohms)
- pin1 and pin2 are not connected in the provided net list.
Documented Code
ESP32-CAM Code
#include "esp_camera.h"
#include <Arduino.h>
#include <WiFi.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <iostream>
#include <sstream>
struct MOTOR_PINS
{
int pinEn;
int pinIN1;
int pinIN2;
};
std::vector<MOTOR_PINS> motorPins =
{
{12, 13, 15}, //RIGHT_MOTOR Pins (EnA, IN1, IN2)
{12, 14, 2}, //LEFT_MOTOR Pins (EnB, IN3, IN4)
};
#define LIGHT_PIN 4
#define UP 1
#define DOWN 2
#define LEFT 3
#define RIGHT 4
#define STOP 0
#define RIGHT_MOTOR 0
#define LEFT_MOTOR 1
#define FORWARD 1
#define BACKWARD -1
const int PWMFreq = 1000; /* 1 KHz */
const int PWMResolution = 8;
const int PWMSpeedChannel = 2;
const int PWMLightChannel = 3;
//Camera related constants
#define PWDN_GPIO_NUM 32
#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
const char* ssid = "MyWiFiCar";
const char* password = "12345678";
AsyncWebServer server(80);
AsyncWebSocket wsCamera("/Camera");
AsyncWebSocket wsCarInput("/CarInput");
uint32_t cameraClientId = 0;
const char* htmlHomePage PROGMEM = R"HTMLHOMEPAGE(
<!DOCTYPE