ESP32-Controlled Ultrasonic Sensor with Dual Motor Driver and I2C LCD Display
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This document provides a detailed overview of a circuit designed to interface an ESP32 microcontroller with various peripherals including a motor driver, DC motors, an ultrasonic sensor, and an I2C LCD display. The circuit is powered by a lithium-ion battery and a small 12V battery, which supply power to the ESP32 and the motor driver, respectively. The ESP32 controls the motor driver, which in turn drives two 250W 12V electric motors. The ultrasonic sensor is interfaced with the ESP32 for distance measurement, and the I2C LCD display is used to output information.
Component List
ESP32
- Microcontroller with WiFi and Bluetooth capabilities.
- Pins: EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, GND, VIN, 3V3, D15, D2, D4, RX2, TX2, D5, D18, D19, D21, RX0, TX0, D22, D23, BOOT.
Lithium-ion Battery 10000mAh
- Power source for the ESP32.
- Pins: 11.1V, GND.
Ultrasonic Sensor
- Sensor for measuring distance via ultrasonic waves.
- Pins: +VCC, Trigger, Echo, GND.
L298N DC Motor Driver
- Module for controlling 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.
250W 12V Electric Motor Brush Motor DC
- Two instances of a high-power DC motor.
- Pins: POSITIF, NEGATIF.
16x2 I2C LCD
- Liquid Crystal Display with I2C communication.
- Pins: GND, VCC, SDA, SCL.
12V Battery (Small Size)
- Power source for the motor driver.
- Pins: VCC, GND.
Wiring Details
ESP32
- D33 connected to L298N DC motor driver ENB.
- D26 connected to L298N DC motor driver ENA.
- GND connected to Lithium-ion Battery GND, Ultrasonic Sensor GND, and 16x2 I2C LCD GND.
- VIN connected to Lithium-ion Battery 11.1V.
- 3V3 connected to Ultrasonic Sensor +VCC.
- RX2 connected to Ultrasonic Sensor Trigger.
- TX2 connected to Ultrasonic Sensor Echo.
- D21 connected to 16x2 I2C LCD SDA.
- D22 connected to 16x2 I2C LCD SCL.
Lithium-ion Battery 10000mAh
- 11.1V connected to ESP32 VIN.
- GND connected to ESP32 GND.
Ultrasonic Sensor
- +VCC connected to ESP32 3V3.
- Trigger connected to ESP32 RX2.
- Echo connected to ESP32 TX2.
- GND connected to ESP32 GND.
L298N DC Motor Driver
- ENB connected to ESP32 D33.
- ENA connected to ESP32 D26.
- OUT1 connected to 250W 12V Electric Motor Brush Motor DC POSITIF.
- OUT2 connected to 250W 12V Electric Motor Brush Motor DC NEGATIF.
- 12V connected to 12V Battery VCC.
- GND connected to 12V Battery GND.
- OUT3 connected to 250W 12V Electric Motor Brush Motor DC NEGATIF (second instance).
- OUT4 connected to 250W 12V Electric Motor Brush Motor DC POSITIF (second instance).
250W 12V Electric Motor Brush Motor DC (First Instance)
- POSITIF connected to L298N DC motor driver OUT1.
- NEGATIF connected to L298N DC motor driver OUT2.
250W 12V Electric Motor Brush Motor DC (Second Instance)
- POSITIF connected to L298N DC motor driver OUT4.
- NEGATIF connected to L298N DC motor driver OUT3.
16x2 I2C LCD
- GND connected to ESP32 GND.
- VCC not connected (requires connection to a power source).
- SDA connected to ESP32 D21.
- SCL connected to ESP32 D22.
12V Battery (Small Size)
- VCC connected to L298N DC motor driver 12V.
- GND connected to L298N DC motor driver GND.
Documented Code
Code for 16x2 I2C LCD (Instance ID: 32a03c59-cd2c-4082-8d10-f3fadb396c4c)
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
Code for 12V Battery (Small Size) (Instance ID: 718f6d32-7e2a-4831-beb4-21c5908ea9ab)
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
(Note: The provided code snippets are placeholders and do not contain any functional code. Actual implementation code is required for the circuit to perform its intended operations.)