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

ESP32-Controlled Omni-Directional AGV with Traffic Light Management and Servo Actuation

Image of ESP32-Controlled Omni-Directional AGV with Traffic Light Management and Servo Actuation

Circuit Documentation

Summary

This circuit is designed to control a three-wheeled omnidirectional AGV (Automated Guided Vehicle) using an ESP32 microcontroller. The circuit includes a servo motor (MG996R) for steering and a traffic light LED system for signaling. The ESP32 controls two L298N DC motor drivers, which in turn drive three DC motors for the movement of the AGV. Additionally, the circuit incorporates MT3608 boost converters to step up the voltage for the motor drivers and a battery mount for power supply.

Component List

Microcontroller

  • ESP32 (30 pin): A microcontroller with WiFi and Bluetooth capabilities, used as the central processing unit for controlling the AGV, servo motor, and traffic light system.

Motor Drivers

  • L298N DC Motor Driver: Used to control the direction and speed of DC motors. Two instances of this component are used to drive three DC motors.

Traffic Light

  • Traffic Light: An LED-based traffic light system with red, yellow, and green indicators, controlled by the ESP32.

Motors

  • DC Motor: Three instances of a standard DC motor, providing the driving force for the AGV's wheels.

Servo Motor

  • MG996R: A high-torque servo motor used for precise control of mechanical movement, likely for steering purposes.

Boost Converters

  • MT3608: A DC-DC step-up converter that boosts the voltage to a higher level. Four instances of this component are used to provide the necessary voltage to the motor drivers.

Power Supply

  • 4 x AAA Battery Mount: Provides the power source for the circuit.

Switch

  • Toggle Switch: A switch to control the power flow in the circuit.

Servo

  • Servo: A generic servo component, possibly an alternative or additional steering mechanism.

Wiring Details

ESP32 (30 pin)

  • D25: Connected to the Green LED of the Traffic Light.
  • D26: Connected to the Yellow LED of the Traffic Light.
  • D27: Connected to the Red LED of the Traffic Light.
  • D14, D23, D22: Control signals for the first L298N DC motor driver.
  • D21, D19, D15: Control signals for the second L298N DC motor driver.
  • D5, D4, D2: Control signals for the third L298N DC motor driver.
  • D18: Signal line for the MG996R servo motor.
  • GND: Common ground for the Traffic Light, both L298N DC motor drivers, and the MG996R servo motor.

L298N DC Motor Driver (First Instance)

  • ENA, IN1, IN2: Controlled by ESP32 for motor operation.
  • ENB, IN3, IN4: Controlled by ESP32 for motor operation.
  • OUT1, OUT2: Connected to the first DC Motor.
  • OUT3, OUT4: Connected to the second DC Motor.
  • 12V: Receives power from MT3608 boost converters.
  • GND: Common ground connection.
  • 5V: Powers the MG996R servo motor.

L298N DC Motor Driver (Second Instance)

  • ENB, IN3, IN4: Controlled by ESP32 for motor operation.
  • OUT3, OUT4: Connected to the third DC Motor.
  • 12V: Receives power from MT3608 boost converters.
  • GND: Common ground connection.

Traffic Light

  • Green, Yellow, Red: Controlled by ESP32.
  • GND: Common ground connection.

DC Motors

  • Each DC Motor has two pins connected to the corresponding OUT pins of the L298N DC motor drivers.

MG996R Servo Motor

  • Signal Line: Controlled by ESP32.
  • Vcc: Powered by the 5V output from the L298N DC motor driver.
  • GND: Common ground connection.

MT3608 Boost Converters

  • VIN+, VIN-: Connected to the 4 x AAA Battery Mount.
  • VOUT+: Powers the L298N DC motor drivers.
  • VOUT-: Common ground connection.

4 x AAA Battery Mount

  • +: Connected to the VIN+ of the MT3608 boost converters.
  • -: Connected to the VIN- of the MT3608 boost converters.

Toggle Switch

  • Used to control the power flow from the battery mount to the circuit.

Servo

  • Not explicitly connected in the provided net list.

Documented Code

/*
 * Carro AGV com três rodas omini multidirecional
 * Controlado por ESP32
 * Inclui controle de servomotor MG996R e semáforo de LED RGB
 */

#include <Servo.h>

// Pin definitions
#define SERVO_PIN 18
#define MOTOR1_ENA 23
#define MOTOR1_IN1 14
#define MOTOR1_IN2 22
#define MOTOR2_ENB 21
#define MOTOR2_IN3 15
#define MOTOR2_IN4 19
#define MOTOR3_ENB 4
#define MOTOR3_IN3 5
#define MOTOR3_IN4 2
#define TRAFFIC_LIGHT_RED 27
#define TRAFFIC_LIGHT_YELLOW 26
#define TRAFFIC_LIGHT_GREEN 25

Servo myservo;

void setup() {
  // Initialize serial communication
  Serial.begin(115200);

  // Initialize servo motor
  myservo.attach(SERVO_PIN);

  // Initialize motor control pins
  pinMode(MOTOR1_ENA, OUTPUT);
  pinMode(MOTOR1_IN1, OUTPUT);
  pinMode(MOTOR1_IN2, OUTPUT);
  pinMode(MOTOR2_ENB, OUTPUT);
  pinMode(MOTOR2_IN3, OUTPUT);
  pinMode(MOTOR2_IN4, OUTPUT);
  pinMode(MOTOR3_ENB, OUTPUT);
  pinMode(MOTOR3_IN3, OUTPUT);
  pinMode(MOTOR3_IN4, OUTPUT);

  // Initialize traffic light pins
  pinMode(TRAFFIC_LIGHT_RED, OUTPUT);
  pinMode(TRAFFIC_LIGHT_YELLOW, OUTPUT);
  pinMode(TRAFFIC_LIGHT_GREEN, OUTPUT);
}

void loop() {
  // Example: Move servo to 90 degrees
  myservo.write(90);
  delay(1000);

  // Example: Control motors
  digitalWrite(MOTOR1_ENA, HIGH);
  digitalWrite(MOTOR1_IN1, HIGH);
  digitalWrite(MOTOR1_IN2, LOW);
  digitalWrite(MOTOR2_ENB, HIGH);
  digitalWrite(MOTOR2_IN3, HIGH);
  digitalWrite(MOTOR2_IN4, LOW);
  digitalWrite(MOTOR3_ENB, HIGH);
  digitalWrite(MOTOR3_IN3, HIGH);
  digitalWrite(MOTOR3_IN4, LOW);
  delay(2000);

  // Stop motors
  digitalWrite(MOTOR1_ENA, LOW);
  digitalWrite(MOTOR2_ENB, LOW);
  digitalWrite(MOTOR3_ENB, LOW);
  delay(1000);

  // Example: Traffic light sequence
  digitalWrite(TRAFFIC_LIGHT_RED, HIGH);
  delay(1000);
  digitalWrite(TRAFFIC_LIGHT_RED, LOW);
  digitalWrite(TRAFFIC_LIGHT_YELLOW, HIGH);
  delay(1000);
  digitalWrite(TRAFFIC_LIGHT_YELLOW, LOW);
  digitalWrite(TRAFFIC_LIGHT_GREEN, HIGH);
  delay(1000);
  digitalWrite(TRAFFIC_LIGHT_GREEN, LOW);
}

This code is responsible for initializing and controlling the various components of the AGV. It sets up the servo motor and the motor drivers, and it includes an example of how to move the servo and control the motors. Additionally, it demonstrates a simple traffic light sequence using the connected LEDs.