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

Arduino UNO-Based Water Quality Monitoring and Cleaning Robot with Turbidity and TDS Sensors

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Water Quality Monitoring and Cleaning Robot with Turbidity and TDS Sensors

Circuit Documentation

Summary

This document provides a detailed overview of a circuit designed to control a robotic system using an Arduino UNO microcontroller. The system includes various sensors, a water pump, DC motors, a servo motor, and a motor driver. The Arduino UNO reads sensor data and controls the actuators based on predefined logic.

Component List

  1. Arduino UNO

    • Description: Microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  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. Turbidity Sensor

    • Description: Sensor to measure the turbidity of water.
    • Pins: OUT, VCC, GND
  4. TDS Sensor Board

    • Description: Sensor to measure Total Dissolved Solids (TDS) in water.
    • Pins: GND, VCC, A
  5. Water Pump

    • Description: Pump to move water.
    • Pins: VCC, GND
  6. Servo Motor

    • Description: Motor for precise control of angular position.
    • Pins: gnd, vcc, pulse
  7. DC Motor

    • Description: Motor for general-purpose use.
    • Pins: pin 1, pin 2
  8. 3.7v LiPo Battery

    • Description: Lithium Polymer battery for power supply.
    • Pins: +Ve, GND

Wiring Details

Arduino UNO

L298N DC Motor Driver

Turbidity Sensor

TDS Sensor Board

Water Pump

Servo Motor

DC Motor (Instance 1)

DC Motor (Instance 2)

3.7v LiPo Battery

Code Documentation

sketch.ino

#include <Servo.h>

// Pins
const int turbidityPin = A0; // Turbidity sensor
const int tdsPin = A1; // TDS sensor
const int pumpPin = 3; // Water pump (PWM output)
const int leftMotorPin = 5; // Left motor
const int rightMotorPin = 6; // Right motor
const int statusLED = 13; // Status LED

Servo roboticArm; // If using a servo-controlled arm

void setup() {
  // Initialize components
  pinMode(turbidityPin, INPUT);
  pinMode(tdsPin, INPUT);
  pinMode(pumpPin, OUTPUT);
  pinMode(leftMotorPin, OUTPUT);
  pinMode(rightMotorPin, OUTPUT);
  pinMode(statusLED, OUTPUT);

  roboticArm.attach(9); // Attach the servo to pin 9
  roboticArm.write(90); // Set initial arm position to neutral

  Serial.begin(9600); // For debugging
}

void loop() {
  // Read turbidity and TDS sensor data
  int turbidityValue = analogRead(turbidityPin);
  int tdsValue = analogRead(tdsPin);

  // Print sensor data
  Serial.print("Turbidity: ");
  Serial.print(turbidityValue);
  Serial.print(" | TDS: ");
  Serial.println(tdsValue);

  // Cleaning logic
  if (turbidityValue > 500 || tdsValue > 700) { // Threshold values
    digitalWrite(statusLED, HIGH); // Turn on LED
    activatePump();
    moveRobot(1, 1); // Move forward
  } else {
    digitalWrite(statusLED, LOW); // Turn off LED
    stopPump();
    moveRobot(0, 0); // Stop
  }

  delay(500); // Small delay for stability
}

// Function to control the water pump
void activatePump() {
  analogWrite(pumpPin, 255); // Full power
}

void stopPump() {
  analogWrite(pumpPin, 0); // Stop pump
}

// Function to move the robot
void moveRobot(int leftMotorSpeed, int rightMotorSpeed) {
  analogWrite(leftMotorPin, leftMotorSpeed * 255);
  analogWrite(rightMotorPin, rightMotorSpeed * 255);
}

documentation.txt

#include <Servo.h>

// Pins
const int turbidityPin = A0;  // Turbidity sensor
const int tdsPin = A1;        // TDS sensor
const int pumpPin = 3;        // Water pump (PWM output)
const int leftMotorPin = 5;   // Left motor
const int rightMotorPin = 6;  // Right motor
const int statusLED = 13;     // Status LED

Servo roboticArm;  // If using a servo-controlled arm

void setup() {
  // Initialize components
  pinMode(turbidityPin, INPUT);
  pinMode(tdsPin, INPUT);
  pinMode(pumpPin, OUTPUT);
  pinMode(leftMotorPin, OUTPUT);
  pinMode(rightMotorPin, OUTPUT);
  pinMode(statusLED, OUTPUT);

  roboticArm.attach(9);  // Attach the servo to pin 9
  roboticArm.write(90);  // Set initial arm position to neutral

  Serial.begin(9600);  // For debugging
}

void loop() {
  // Read turbidity and TDS sensor data
  int turbidityValue = analogRead(turbidityPin);
  int tdsValue = analogRead(tdsPin);

  // Print sensor data
  Serial.print("Turbidity: ");
  Serial.print(turbidityValue);
  Serial.print(" | TDS: ");
  Serial.println(tdsValue);

  // Cleaning logic
  if (turbidityValue > 500 ||