ESP32-Controlled Robotic Vehicle with Voice Recognition and Ultrasonic Sensing
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
The circuit in question appears to be designed for a mobile robotic platform, featuring motor control, servo actuation, and distance sensing capabilities. The central processing unit is an ESP32 microcontroller, which interfaces with an L298N DC motor driver to control the motion of the robot's wheels. Additionally, the circuit includes a servo motor for actuation purposes and an HC-SR04 ultrasonic sensor for distance measurement. Power is supplied by a 4 x AAA battery mount.
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
Gearmotor DC Wheels (Left and Right)
- Description: DC gearmotors used for the robot's wheels.
- Pins: PIN1, PIN2
4 x AAA Battery Mount
- Description: A battery holder for four AAA batteries, providing power to the circuit.
- Pins: -, +
ESP32 (30 pin)
- Description: A microcontroller with Wi-Fi and Bluetooth capabilities, used as the main controller for the robot.
- 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
Servo
- Description: A servo motor for actuation purposes.
- Pins: GND, VCC, PWM
HC-SR04 Ultrasonic Sensor
- Description: An ultrasonic distance sensor for measuring distances to obstacles.
- Pins: VCC, TRIG, ECHO, GND
Wiring Details
L298N DC Motor Driver
- ENB connected to ESP32 D35
- IN4 connected to ESP32 D32
- IN3 connected to ESP32 D33
- IN2 connected to ESP32 D25
- IN1 connected to ESP32 D26
- ENA connected to ESP32 D27
- 12V connected to 4 x AAA Battery Mount +
- GND connected to 4 x AAA Battery Mount -
- OUT1 connected to Left Gearmotor DC Wheels PIN1 and Right Gearmotor DC Wheels PIN2
- OUT2 connected to Left Gearmotor DC Wheels PIN2 and Right Gearmotor DC Wheels PIN1
- OUT3 connected to Right Gearmotor DC Wheels PIN1 and Left Gearmotor DC Wheels PIN1
- OUT4 connected to Right Gearmotor DC Wheels PIN2 and Left Gearmotor DC Wheels PIN2
Gearmotor DC Wheels (Left and Right)
- No direct connections to the ESP32. Controlled via the L298N motor driver.
4 x AAA Battery Mount
-
- connected to L298N DC motor driver 12V
-
- connected to L298N DC motor driver GND
ESP32 (30 pin)
- D35 connected to L298N DC motor driver ENB
- D32 connected to L298N DC motor driver IN4
- D33 connected to L298N DC motor driver IN3
- D25 connected to L298N DC motor driver IN2
- D26 connected to L298N DC motor driver IN1
- D27 connected to L298N DC motor driver ENA
- D14 connected to Servo PWM
- D12 connected to HC-SR04 Ultrasonic Sensor TRIG
- D13 connected to HC-SR04 Ultrasonic Sensor ECHO
- GND connected to HC-SR04 Ultrasonic Sensor GND, Servo GND
- Vin connected to HC-SR04 Ultrasonic Sensor VCC, Servo VCC
Servo
- PWM connected to ESP32 D14
- VCC connected to ESP32 Vin
- GND connected to ESP32 GND
HC-SR04 Ultrasonic Sensor
- TRIG connected to ESP32 D12
- ECHO connected to ESP32 D13
- VCC connected to ESP32 Vin
- GND connected to ESP32 GND
Documented Code
ESP32 Microcontroller Code (sketch.ino)
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
Additional Code Documentation (documentation.txt)
VAIO Code logic
## Setup
- Motor Wheels Setup task
- Ultrasonic Setup task (For automatic)
- Bluetooth Setup task (for DS4)
- ESP Now Setup (For hand gesture & Voice Recognition)
## Operational
- Master Controller Task (Handles the state of communication) (Priority 2)
- Voice Recognition Task (Probably uses Interrupt i.e has the highest priority) (Priority 1)
- Automatic Task (uses ultrasonic) (Priority 3)
- DS4 Task (uses bluetooth) (Priority 3)
- Hand Gesture Task (uses ESP-NOW) (Priority 3)
### Voice Recognition Task (Called when interrupted by the voice module from the hand gesture ESP32)
- ESP-NOW communication has to be always active for voice communication
### Master Controller Task (Called everytime by Voice Recognition Task)
- This task will be execute by Voice Recognition Task
- Implement enums for the state
- Calls either the Automatic Task, DS4 Task, or Hand Gesture Task depending on the state
### Automatic Task (Task is looping)
- This task will be execute by Master Controller Task
### DS4 Task (Task is looping)
- This task will be execute by Master Controller Task
### Hand Gesture Task (Task is looping)
- This task will be execute by Master Controller Task
## Some logic ideas
ESP32 has 2 cores. Core 1 execute Master Controller Task. Core 2 execute Voice Recognition Task
Voice Recognition Task in Core 2 will always be ready to listen for ESP-NOW communication for the voice command. If communication has been heard,
it will process the command and interrupt task in Core 1 by calling the Master Controller Task to change the state of the controls.
Note: Keep in mind of accidentally resetting the watchdog timer
This documentation provides an overview of the circuit, including the components used, their wiring, and the code that will be running on the ESP32 microcontroller. The code snippets and additional documentation outline the intended logic and operational tasks for the robotic platform.