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

ESP32-Powered Waterway Trash Collector with Ultrasonic Monitoring and DC Motors

View and Edit Project In Cirkit DesignerImage of ESP32-Powered Waterway Trash Collector with Ultrasonic Monitoring and DC Motors

Waterway Trash Collector with Monitoring

Summary

This project involves a waterway trash collector system that uses an ESP32 microcontroller to control three DC motors for movement and one DC motor for a conveyor. An ultrasonic sensor is used to detect the trash level. The system is powered by two 18650 Li-ion batteries. The ESP32 microcontroller interfaces with two L298N DC motor drivers to control the motors, and an HC-SR04 ultrasonic sensor to monitor the trash level.

Component List

ESP32 - 38 pins

L298N DC Motor Driver (2 units)

DC Motor (4 units)

18650 Li-ion Battery x 2

HC-SR04 Ultrasonic Sensor

AMB82-Mini IoT AI Camera

Wiring Details

ESP32 - 38 pins

L298N DC Motor Driver (1st unit)

L298N DC Motor Driver (2nd unit)

DC Motor (1st unit)

DC Motor (2nd unit)

DC Motor (3rd unit)

DC Motor (4th unit)

18650 Li-ion Battery x 2

HC-SR04 Ultrasonic Sensor

Code Documentation

/*
 * Waterway Trash Collector with Monitoring
 * This code controls three DC motors for movement and one DC motor for a conveyor
 * using an ESP32 microcontroller. An ultrasonic sensor is used to detect the trash
 * level.
 */

// Motor driver pins
const int motor1_ENA = 26;
const int motor1_IN1 = 25;
const int motor1_IN2 = 33;
const int motor2_ENB = 34;
const int motor2_IN3 = 32;
const int motor2_IN4 = 35;
const int motor3_ENA = 23;
const int motor3_IN1 = 22;
const int motor3_IN2 = 21;
const int motor3_IN3 = 19;
const int motor3_IN4 = 18;
const int motor4_ENB = 5;

// Ultrasonic sensor pins
const int trigPin = 17;
const int echoPin = 16;

void setup() {
  Serial.begin(115200);

  // Motor pins setup
  pinMode(motor1_ENA, OUTPUT);
  pinMode(motor1_IN1, OUTPUT);
  pinMode(motor1_IN2, OUTPUT);
  pinMode(motor2_ENB, OUTPUT);
  pinMode(motor2_IN3