Course Content
Hands-On ESP32 Robotics: Build Smart Robots Step by Step

Circuit Connections (Limit Switch Module)

🎯 Lesson Objective

In this lesson, students will understand:

• How to connect the limit switch module to the ESP32
• How to connect the L298N motor driver to the ESP32
• How to connect DC motors to the motor driver
• The importance of proper wiring in robotics systems

This lesson explains the hardware connections required to build the Single Limit Switch Bumper Robot.


1️⃣ Understanding the Circuit

Before writing the program, all hardware components must be connected correctly.

In this project, the main components connected to the ESP32 are:

🧠 ESP32 microcontroller
🔘 Limit Switch Module (front bumper sensor)
⚙ L298N motor driver
🚗 DC motors

The ESP32 reads the signal from the limit switch module and controls the motors through the motor driver.


2️⃣ Limit Switch Module Connections

The limit switch module is mounted at the front of the robot so that it gets pressed when the robot touches an obstacle.

Most limit switch modules have three pins:

• VCC
• GND
• OUT (Signal)

Limit Switch Module Pin Connections

Limit Switch Pin ESP32 Connection
VCC 3.3V
GND GND
OUT GPIO 32

Connection Explanation

The OUT pin sends a digital signal to the ESP32.

The module already contains the required resistor circuit, so we do not need to use an internal pull-up resistor.

The signal behavior is:

Switch not pressed → HIGH signal
Switch pressed → LOW signal

This allows the ESP32 to detect when the robot hits an obstacle.


3️⃣ Motor Driver Connections

The L298N motor driver controls the two DC motors.

Motor Driver Input Pins

L298N Pin ESP32 Connection
IN1 GPIO 26
IN2 GPIO 27
IN3 GPIO 14
IN4 GPIO 12

These pins control the direction of the motors.

The ESP32 sends HIGH or LOW signals to control motor movement.


4️⃣ Motor Connections

The DC motors are connected to the motor driver output terminals.

Motor Driver Output Connections

Motor Driver Output Motor
OUT1 Left Motor Terminal 1
OUT2 Left Motor Terminal 2
OUT3 Right Motor Terminal 1
OUT4 Right Motor Terminal 2

These outputs provide power to the motors and control their rotation direction.


5️⃣ Motor Driver Power Connections

The motor driver requires a separate power supply.

Power Wiring

Motor Driver Pin Connection
12V Battery Positive
GND Battery Ground
5V ESP32 logic power (Vin Pin)

The battery powers the motors, while the ESP32 only sends control signals.


6️⃣ Importance of Common Ground

All devices in the system must share a common ground connection.

This means connecting together:

• ESP32 ground
• Motor driver ground
• Limit switch module ground
• Battery ground

A common ground ensures proper signal communication between all components.


7️⃣ Checking the Circuit Before Powering

Before turning on the robot, verify the following:

✔ Limit switch module connected correctly
✔ Motor driver input pins connected to ESP32
✔ Motors connected to correct terminals
✔ Battery polarity correct
✔ No loose wires

Incorrect wiring may prevent the robot from working or damage components.


8️⃣ Circuit Working Overview

The circuit operates as follows:

1️⃣ The robot moves forward.
2️⃣ When the robot touches an obstacle, the limit switch module is pressed.
3️⃣ The module sends a LOW signal to the ESP32.
4️⃣ The ESP32 processes the signal.
5️⃣ The ESP32 sends commands to the motor driver.
6️⃣ The robot moves backward and turns.

This allows the robot to detect obstacles and change direction automatically.


🚀 What Happens Next

Now that the hardware connections are complete, the next step is to write the program that controls the robot behavior.

Scroll to Top