🔌 Circuit Connections
🎯 Lesson Objective
In this lesson, students will understand:
• How to connect the components for the Smart Dustbin project
• How the ultrasonic sensor is connected to the ESP32
• How the servo motor is connected to the ESP32
• The importance of correct wiring in robotics systems
This lesson explains the hardware connections required to build the Smart Dustbin system.
1️⃣ Understanding the Circuit
Before writing the program, all hardware components must be connected correctly.
In the Smart Dustbin project, the main components connected to the ESP32 are:
🧠 ESP32 microcontroller
📏 Ultrasonic sensor (HC-SR04)
🔄 Servo motor
Each component must be connected to the correct power pins and GPIO pins.
Proper wiring ensures that the ESP32 can communicate with the sensors and control the servo motor.
2️⃣ Ultrasonic Sensor Connections
The HC-SR04 ultrasonic sensor has four pins.
Each pin must be connected correctly to the ESP32.
Ultrasonic Sensor Pin Connections
| Ultrasonic Pin | ESP32 Connection |
|---|---|
| VCC | 5V |
| GND | GND |
| TRIG | GPIO 5 |
| ECHO | GPIO 18 |
Connection Explanation
🔴 VCC supplies power to the sensor.
⚫ GND connects the sensor to the ground of the circuit.
🟡 TRIG pin sends the ultrasonic signal from the ESP32 to start the measurement.
🔵 ECHO pin sends the measured signal back to the ESP32.
The ESP32 uses this information to calculate the distance between the sensor and an object.
3️⃣ Servo Motor Connections
The servo motor is responsible for opening and closing the dustbin lid.
Most servo motors have three wires.
Servo Motor Pin Connections
| Servo Wire | ESP32 Connection |
|---|---|
| Red | 5V |
| Brown / Black | GND |
| Yellow / Orange | GPIO 4 |
Connection Explanation
🔴 Red wire provides power to the servo motor.
⚫ Brown or black wire connects to ground.
🟡 Yellow or orange wire receives the PWM control signal from the ESP32.
The ESP32 sends PWM signals through this pin to control the angle of the servo motor.
4️⃣ Importance of Common Ground
When connecting multiple components, it is important that all devices share a common ground.
This means:
• The ESP32 ground
• The sensor ground
• The servo motor ground
All must be connected together.
A common ground ensures proper electrical communication between devices.
5️⃣ Checking the Circuit Before Powering
Before powering the circuit, it is important to verify the connections.
Check the following:
✔ Sensor pins connected correctly
✔ Servo wires connected correctly
✔ Power and ground connections secure
✔ No loose wires
Incorrect wiring can prevent the system from functioning or may damage components.
6️⃣ Circuit Overview
The complete circuit works as follows:
1️⃣ The ultrasonic sensor detects the distance to an object.
2️⃣ The sensor sends the signal to the ESP32.
3️⃣ The ESP32 processes the sensor data.
4️⃣ The ESP32 sends a PWM signal to the servo motor.
5️⃣ The servo motor opens or closes the dustbin lid.
This simple circuit allows the Smart Dustbin to operate automatically.
🚀 What Happens Next
Now that the hardware connections are completed, the next step is to write the program that controls the Smart Dustbin system.