Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Wi-Fi Controlled Robotic Car with ESP32 and L298N Motor Drivers

View and Edit Project In Cirkit DesignerImage of Wi-Fi Controlled Robotic Car with ESP32 and L298N Motor Drivers

Circuit Documentation

Summary

This document provides a detailed overview of a circuit designed to control multiple motors and sensors using an ESP32 microcontroller. The circuit includes motor drivers, various sensors, and a GPS module. The ESP32 is programmed to communicate with Firebase for remote control and monitoring.

Component List

  1. Motor and Wheels

    • Description: DC motor with attached wheels.
    • Pins: VCC, GND
  2. L298N DC Motor Driver

    • Description: Dual H-Bridge motor driver.
    • 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
  3. ESP32

    • Description: Wi-Fi and Bluetooth microcontroller.
    • 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
  4. Battery 12V

    • Description: 12V power supply.
    • Pins: +, -
  5. HC-SR04 Ultrasonic Distance Sensor

    • Description: Ultrasonic sensor for distance measurement.
    • Pins: VCC, TRIG, ECHO, GND
  6. Servo

    • Description: Servo motor.
    • Pins: GND, VCC, PWM
  7. Rain Sensor

    • Description: Sensor to detect rain.
    • Pins: AO, DO, GRD, VCC
  8. MQ-2

    • Description: Gas sensor.
    • Pins: GND, VCC, ANALOG, Digital
  9. GPS NEO 6M

    • Description: GPS module.
    • Pins: VCC, RX, TX, GND

Wiring Details

Motor and Wheels

L298N DC Motor Driver

ESP32

Battery 12V

HC-SR04 Ultrasonic Distance Sensor

Servo

Rain Sensor

MQ-2

GPS NEO 6M

Documented Code

ESP32 Code

#include <FirebaseESP32.h>
#include <WiFi.h>

#define FIREBASE_HOST "https://console.firebase.google.com/u/0/project/acar-ec140/database/acar-ec140-default-rtdb/data/~2F"
#define FIREBASE_AUTH "AIzaSyB9oe-hKiQZIaRjAoKtSYzPcfa61ICXLoY"
#define WIFI_SSID "space"
#define WIFI_PASSWORD "cosmic07"

#define RX_PIN 16
#define TX_PIN 17

FirebaseData firebaseData;
String controlMode;

void setup() {
  Serial.begin(115200); // ESP32 UART for debugging
  Serial2.begin(9600, SERIAL_8N1, RX_PIN, TX_PIN); // ESP32 UART for communication with Arduino

  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to Wi-Fi...");
  }
  Serial.println("Connected to Wi-Fi");

  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
}

void loop() {
  if (Firebase.getString(firebaseData, "/controlMode")) {
    controlMode = firebaseData.stringData();
    Serial.println("Control Mode: " + controlMode);
    Serial2.println(controlMode); // Send control mode to Arduino
  }

  if (controlMode == "manual") {
    if (Firebase.getString(firebaseData, "/commands")) {
      String command = firebaseData.stringData();
      Serial.println("Command: " + command);
      Serial2.println(command); // Send command to Arduino
    }
  }

  delay(100); // Reduce Firebase polling rate
}

Battery 12V Code

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

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

This documentation provides a comprehensive overview of the circuit, including component descriptions, wiring details, and the code used for the ESP32 microcontroller.