Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

ESP32-Controlled Robot with Ultrasonic Obstacle Avoidance and RGB LED Feedback

Image of ESP32-Controlled Robot with Ultrasonic Obstacle Avoidance and RGB LED Feedback

Circuit Documentation

Summary

This circuit is designed to control a DC Mini Metal Gear Motor using an L298N DC motor driver, which is interfaced with an ESP32 Wroom microcontroller. The circuit also includes an HC-SR04 Ultrasonic Sensor for distance measurement, a WS2812 RGB LED strip for visual feedback, and a 12v 7ah Battery as the power source. A Step down Buck converter is used to step down the voltage for components requiring lower voltage levels. The circuit also incorporates resistors for current limiting and a phototransistor for light sensing.

Component List

L298N DC Motor Driver

  • Description: A motor driver module capable of driving two DC motors or one stepper motor.
  • 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

HC-SR04 Ultrasonic Sensor

  • Description: An ultrasonic sensor used for measuring distances using sound waves.
  • Pins: VCC, TRIG, ECHO, GND

DC Mini Metal Gear Motor

  • Description: A compact DC motor with a gearbox for increased torque.
  • Pins: IN1, IN2

ESP32 Wroom

  • Description: A powerful microcontroller with Wi-Fi and Bluetooth capabilities.
  • Pins: 3V3, Reset, GPIOs, GND, 5V, etc.

12v 7ah Battery

  • Description: A rechargeable battery providing a 12V power source.
  • Pins: 12v +, 12v -

WS2812 RGB LED Strip

  • Description: An addressable LED strip capable of displaying multiple colors.
  • Pins: DIN, 5V, GND, DO

Step Down Buck Converter

  • Description: A voltage regulator that steps down voltage from a higher level to a lower level.
  • Pins: IN +, IN - GND, OUT +, OUT - GND

Resistor (200 Ohms)

  • Description: A passive two-terminal electrical component that implements electrical resistance.
  • Pins: pin1, pin2

Resistor (10k Ohms)

  • Description: Another resistor with a higher resistance value.
  • Pins: pin1, pin2

Phototransistor

  • Description: A light-sensitive transistor.
  • Pins: C (Collector), E (Emitter)

Wiring Details

L298N DC Motor Driver

  • OUT1 connected to DC Mini Metal Gear Motor IN1
  • OUT2 connected to DC Mini Metal Gear Motor IN2
  • 12V connected to 12v 7ah Battery 12v + and Step down Buck converter IN +
  • GND connected to 12v 7ah Battery 12v -, Step down Buck converter IN - GND, and ESP32 Wroom GND
  • ENA connected to ESP32 Wroom GPIO25
  • IN1 connected to ESP32 Wroom GPIO1/TXD0
  • IN2 connected to ESP32 Wroom GPIO3/RXD0

HC-SR04 Ultrasonic Sensor

  • VCC connected to Step down Buck converter OUT +
  • TRIG connected to ESP32 Wroom GPIO16
  • ECHO connected to ESP32 Wroom GPIO17
  • GND connected to ESP32 Wroom GND

DC Mini Metal Gear Motor

  • IN1 connected to L298N DC Motor Driver OUT1
  • IN2 connected to L298N DC Motor Driver OUT2

ESP32 Wroom

  • 5V connected to Step down Buck converter OUT + and WS2812 RGB LED strip 5V
  • GND connected to L298N DC Motor Driver GND, WS2812 RGB LED strip GND, Step down Buck converter OUT - GND, Phototransistor C, and HC-SR04 Ultrasonic Sensor GND
  • GPIO25 connected to L298N DC Motor Driver ENA
  • GPIO1/TXD0 connected to L298N DC Motor Driver IN1
  • GPIO3/RXD0 connected to L298N DC Motor Driver IN2
  • GPIO16 connected to HC-SR04 Ultrasonic Sensor TRIG
  • GPIO17 connected to HC-SR04 Ultrasonic Sensor ECHO
  • GPIO34 connected to Resistor (10k Ohms) pin2
  • GPIO5 connected to Resistor (200 Ohms) pin2

WS2812 RGB LED Strip

  • 5V connected to Step down Buck converter OUT +
  • GND connected to ESP32 Wroom GND
  • DIN connected to Resistor (200 Ohms) pin1

Step Down Buck Converter

  • IN + connected to 12v 7ah Battery 12v +
  • IN - GND connected to 12v 7ah Battery 12v -
  • OUT + connected to ESP32 Wroom 5V, WS2812 RGB LED strip 5V, and HC-SR04 Ultrasonic Sensor VCC
  • OUT - GND connected to ESP32 Wroom GND

Resistor (200 Ohms)

  • pin1 connected to WS2812 RGB LED strip DIN
  • pin2 connected to ESP32 Wroom GPIO5

Resistor (10k Ohms)

  • pin1 connected to Phototransistor E
  • pin2 connected to ESP32 Wroom GPIO34

Phototransistor

  • C connected to ESP32 Wroom GND
  • E connected to Resistor (10k Ohms) pin1

Documented Code

ESP32 Wroom Microcontroller Code (sketch.ino)

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

Note: The provided code is a template and does not contain any functional code. It needs to be populated with the logic to control the motor, read the ultrasonic sensor, and manage the LED strip based on the requirements of the circuit's application.