ESP32 and L298N Motor Driver-Based Wi-Fi Controlled Robotic Car with Ultrasonic Sensor
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This document provides a detailed overview of a circuit designed to control two DC motors using an ESP32 microcontroller, an L298N motor driver, and an HC-SR04 ultrasonic sensor. The circuit is powered by a 5V battery and a 2200mAh LiPo battery. The ESP32 microcontroller is programmed to control the motor driver and read data from the ultrasonic sensor.
Component List
L298N DC Motor Driver
- Description: A dual H-Bridge motor driver that allows control of the speed and direction of two DC motors.
- Pins: OUT1, OUT2, 12V, GND, 5V, OUT3, OUT4, 5V-ENA-JMP-I, 5V-ENA-JMP-O, +5V-J1, +5V-J2, ENA, IN1, IN2, IN3, IN4, ENB
DC Motor (Motor 1)
- Description: A standard DC motor.
- Pins: pin 1, pin 2
DC Motor (Motor 2)
- Description: A standard DC motor.
- Pins: pin 1, pin 2
LiPo Battery 2200mAh 30C
- Description: A high-capacity LiPo battery used to power the motor driver.
- Pins: VCC, GND
ESP32 (30 pin)
- Description: A powerful microcontroller with built-in Wi-Fi and Bluetooth capabilities.
- Pins: EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, GND, Vin, D23, D22, TX0, RX0, D21, D19, D18, D5, TX2, RX2, D4, D2, D15, 3V3
HC-SR04 Ultrasonic Sensor
- Description: A sensor used to measure distance by using ultrasonic waves.
- Pins: VCC, TRIG, ECHO, GND
5V Battery
- Description: A 5V battery used to power the ESP32 and the ultrasonic sensor.
- Pins: +, -
Wiring Details
L298N DC Motor Driver
- ENA connected to D23 of ESP32
- ENB connected to D22 of ESP32
- IN1 connected to D19 of ESP32
- IN2 connected to D18 of ESP32
- IN3 connected to D2 of ESP32
- IN4 connected to D5 of ESP32
- 5V connected to + of 5V Battery
- GND connected to GND of LiPo Battery
- 12V connected to VCC of LiPo Battery
- OUT1 connected to pin 2 of DC Motor (Motor 2)
- OUT2 connected to pin 1 of DC Motor (Motor 2)
- OUT3 connected to pin 2 of DC Motor (Motor 1)
- OUT4 connected to pin 1 of DC Motor (Motor 1)
DC Motor (Motor 1)
- pin 1 connected to OUT4 of L298N DC Motor Driver
- pin 2 connected to OUT3 of L298N DC Motor Driver
DC Motor (Motor 2)
- pin 1 connected to OUT2 of L298N DC Motor Driver
- pin 2 connected to OUT1 of L298N DC Motor Driver
LiPo Battery 2200mAh 30C
- VCC connected to 12V of L298N DC Motor Driver
- GND connected to GND of L298N DC Motor Driver
ESP32 (30 pin)
- D33 connected to ECHO of HC-SR04 Ultrasonic Sensor
- D27 connected to TRIG of HC-SR04 Ultrasonic Sensor
- GND connected to - of 5V Battery
- D23 connected to ENA of L298N DC Motor Driver
- D22 connected to ENB of L298N DC Motor Driver
- D19 connected to IN1 of L298N DC Motor Driver
- D18 connected to IN2 of L298N DC Motor Driver
- D5 connected to IN4 of L298N DC Motor Driver
- D2 connected to IN3 of L298N DC Motor Driver
- 3V3 connected to + of 5V Battery
HC-SR04 Ultrasonic Sensor
- ECHO connected to D33 of ESP32
- TRIG connected to D27 of ESP32
- GND connected to GND of 5V Battery
- VCC connected to + of 5V Battery
5V Battery
- + connected to 3V3 of ESP32
- - connected to GND of ESP32
Documented Code
sketch.ino
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
documentation.txt