ESP32-Controlled Quadruple DC Motor Driver with Ultrasonic Sensing
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to control multiple DC motors using ESP32 Devkit V1 microcontroller and L298N DC motor drivers. It also includes an HC-SR04 Ultrasonic Sensor for distance measurement. The ESP32 microcontroller interfaces with the motor drivers to control the direction and speed of the motors and reads the distance from the ultrasonic sensor. The circuit is powered by a 9V battery, which supplies power to the motor drivers and the microcontroller.
Component List
ESP32 Devkit V1
- Microcontroller with WiFi and Bluetooth capabilities.
- It has multiple digital I/O pins and analog inputs.
- Utilized for controlling the motor drivers and reading sensor data.
L298N DC Motor Driver (x2)
- A module capable of driving two DC motors.
- It has pins for motor outputs, power supply, and control inputs.
- Used to control the direction and speed of the connected DC motors.
HC-SR04 Ultrasonic Sensor
- A sensor for measuring distances using ultrasonic waves.
- It has pins for VCC, Trigger, Echo, and Ground.
- Used to measure the distance to objects in front of the sensor.
DC Motor (x4)
- A simple DC motor with two connection pins.
- Used as the actuator in the circuit.
9V Battery
- A standard 9V battery with positive and negative terminals.
- Provides power to the circuit.
Wiring Details
ESP32 Devkit V1
3V3connected to HC-SR04 Ultrasonic SensorVCCGNDconnected to the ground of both L298N DC motor drivers and HC-SR04 Ultrasonic SensorD18connected to L298N DC motor driverENBD19connected to L298N DC motor driverIN4D21connected to L298N DC motor driverIN3RX0connected to L298N DC motor driverIN2TX0connected to L298N DC motor driverIN1D22connected to L298N DC motor driverENAD34connected to the second L298N DC motor driverENAD35connected to the second L298N DC motor driverIN1D32connected to the second L298N DC motor driverIN2D33connected to the second L298N DC motor driverIN3D25connected to the second L298N DC motor driverIN4D26connected to the second L298N DC motor driverENBD12connected to HC-SR04 Ultrasonic SensorTRIGD13connected to HC-SR04 Ultrasonic SensorECHOVINconnected to the positive terminal of the 9V Battery
L298N DC Motor Driver (1st instance)
GNDconnected to ESP32 Devkit V1GNDand 9V Battery-12Vconnected to the positive terminal of the 9V BatteryOUT1andOUT2connected to the first DC MotorOUT3andOUT4connected to the second DC Motor
L298N DC Motor Driver (2nd instance)
GNDconnected to ESP32 Devkit V1GNDand 9V Battery-12Vconnected to the positive terminal of the 9V BatteryOUT1andOUT2connected to the third DC MotorOUT3andOUT4connected to the fourth DC Motor
HC-SR04 Ultrasonic Sensor
VCCconnected to ESP32 Devkit V13V3TRIGconnected to ESP32 Devkit V1D12ECHOconnected to ESP32 Devkit V1D13GNDconnected to ESP32 Devkit V1GND
DC Motors
- Each DC Motor has two pins connected to the corresponding outputs of the L298N DC motor drivers.
9V Battery
+connected to the12Vinput of both L298N DC motor drivers and ESP32 Devkit V1VIN-connected to the ground of both L298N DC motor drivers and ESP32 Devkit V1GND
Documented Code
There is no code provided for the microcontroller. The code would typically initialize the GPIO pins for motor control and ultrasonic sensor interfacing, set up PWM for speed control, and include routines to read the sensor and control the motors based on the sensor input.