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

Arduino-Controlled pH Monitoring and Adjustment System with Servo-Operated Alarms

View and Edit Project In Cirkit DesignerImage of Arduino-Controlled pH Monitoring and Adjustment System with Servo-Operated Alarms

Circuit Documentation

Summary

This circuit is designed to monitor the pH level of a solution and respond to extreme pH values by activating an alarm and controlling a water pump. The system uses an Arduino UNO as the central microcontroller to read pH values from a pH meter, display the readings on an I2C LCD screen, and control two micro servos, a buzzer, and a water pump through a 5V relay. The circuit is powered by a battery, and the components are interconnected through various digital and analog pins on the Arduino UNO.

Component List

Microcontroller

Sensors

Actuators

Power Supply

Display

Relay

Wiring Details

Arduino UNO

Micro servo 9G

PH Meter

I2C LCD 16x2 Screen

5v relay

5v mini water pump

buzzer

Documented Code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);  // Initialize the I2C LCD (address may vary)

const int pHSensorPin = A0;
const int buzzerPin = 7;
const int waterPumpPin = 8;
const int servoPin1 = 9;
const int servoPin2 = 10;

Servo servo1;
Servo servo2;

void setup() {
  // Initialize components
  lcd.begin(16, 2);  // Set LCD size to 16x2
  lcd.backlight();

  servo1.attach(servoPin1);
  servo2.attach(servoPin2);
  pinMode(buzzerPin, OUTPUT);
  pinMode(waterPumpPin, OUTPUT);

  // Set initial states
  digitalWrite(buzzerPin, LOW);
  digitalWrite(waterPumpPin, LOW);
  servo1.write(0);  // Set servos to 0 degrees initially
  servo2.write(0);
}

void loop() {
  float pHValue = analogRead(pHSensorPin) * (5.0 / 1023.0) * 3.5;  // Adjust 3.5 factor based on sensor calibration

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("pH Value: ");
  lcd.print(pHValue);

  if (pHValue < 4.0) {
    lcd.setCursor(0, 1);
    lcd.print("Acidic");
    activateAlarm();
  } 
  else if (pHValue > 10.0) {
    lcd.setCursor(0, 1);
    lcd.print("Basic");
    activateAlarm();
  } 
  else {
    lcd.setCursor(0, 1);
    lcd.print("Neutral");
    deactivateAlarm();
  }

  delay(1000);  // Wait 1 second before next reading
}

void activateAlarm() {
  servo1.write(90);  // Rotate servos to 90 degrees
  servo2.write(90);
  digitalWrite(buzzerPin, HIGH);  // Turn on buzzer
  delay(2000);  // Wait for 2 seconds
  digitalWrite(waterPumpPin, HIGH);  // Start water pump
}

void deactivateAlarm() {
  digitalWrite(buzzerPin, LOW);  // Turn off buzzer
  digitalWrite(waterPumpPin, LOW);  // Turn off water pump
  servo1.write(0);  // Return servos to original position
  servo2.write(0);
}

This code is designed to run on the Arduino UNO microcontroller. It initializes the connected components, reads the pH value from the sensor, displays the value on the LCD, and activates or deactivates the alarm and water pump based on the pH level. The servos are used as part of the alarm mechanism, presumably to perform a physical action when the alarm state is activated.