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

Arduino and ESP32-Based Smart Water Quality Monitoring System with Motor Control

View and Edit Project In Cirkit DesignerImage of Arduino and ESP32-Based Smart Water Quality Monitoring System with Motor Control

Circuit Documentation

Summary

This document provides a detailed overview of a circuit that integrates various sensors, motor drivers, and microcontrollers to perform multiple tasks. The circuit includes an Arduino UNO, an ESP32-WROOM-32UE, a L298N DC motor driver, and several sensors such as a TDS sensor, a turbidity module, a pH degree sensor module, an HX711 bridge sensor interface, and a load cell. The circuit is powered by a 12V battery and is designed to control motors and read sensor data, which is then transmitted to a Blynk application for monitoring.

Component List

Arduino UNO

L298N DC Motor Driver

ESP32-WROOM-32UE

Battery 12V

HX711 - Bridge Sensor Interface

Load Cell - Red/White/Black/Green

Turbidity Module

TDS Sensor

pH Degree Sensor Module

775 Motor

Geared Motor

Wiring Details

Arduino UNO

L298N DC Motor Driver

ESP32-WROOM-32UE

HX711 - Bridge Sensor Interface

Battery 12V

Documented Code

Arduino UNO Code

#include <AFMotor.h>
#include "HX711.h"
#include <Wire.h>

// Define pin connections
#define conveyorMotorPin 9    // Pin for controlling the conveyor motor
#define TURBIDITY_PIN A2      // Pin for reading turbidity data
#define PH_PIN A3             // Pin for reading pH data
#define TDS_PIN A4            // Pin for reading TDS data
#define RX_PIN 0              // Arduino RX connected to ESP32 TX
#define TX_PIN 1              // Arduino TX connected to ESP32 RX

// Initialize motor drivers
AF_DCMotor motorLeft(1);      // Left motor connected to M1
AF_DCMotor motorRight(2);     // Right motor connected to M2

// Initialize the HX711 weight sensor
HX711 scale;

void setup() {
  Serial.begin(9600); // Initialize serial communication for debugging

  // Initialize motors
  motorLeft.setSpeed(150); // Set left motor speed (0-255)
  motorRight.setSpeed(150); // Set right motor speed (0-255)
  pinMode(conveyorMotorPin, OUTPUT); // Set conveyor motor pin as output

  // Initialize HX711
  scale.begin(A0, A1); // Connect DATA to A0, CLOCK to A1
  scale.set_scale(2280.f); // Adjust calibration factor based on your load cell
  scale.tare(); // Reset the scale to 0 weight

  // Print initialization message
  Serial.println("Setup complete. Starting operations...");
}

void moveMotors(int direction, int duration) {
  if (direction == FORWARD) {
    motorLeft.run(FORWARD);
    motorRight.run(FORWARD);
  } else if (direction == BACKWARD) {
    motorLeft.run(BACKWARD);
    motorRight.run(BACKWARD);
  } else {
    motorLeft.run(RELEASE);
    motorRight.run(RELEASE);
  }
  delay(duration); // Duration of movement
  motorLeft.run(RELEASE);
  motorRight.run(RELEASE); // Stop motors
}

void operateConveyor(int speed, int duration) {
  analogWrite(conveyorMotorPin, speed); // Set conveyor motor speed
  delay(duration); // Duration of conveyor operation
  analogWrite(conveyorMotorPin, 0); // Stop conveyor motor
}

void readSensors() {
  // Read and display weight from HX711