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

ESP32-Based Automated pH Monitoring and Water Pump Control System

View and Edit Project In Cirkit DesignerImage of ESP32-Based Automated pH Monitoring and Water Pump Control System

Circuit Documentation

Summary

This document provides a detailed overview of a circuit designed to control a water pump and measure pH levels using an ESP32 microcontroller. The circuit includes various components such as a power supply, a DC motor driver, a relay, and a pH meter. The ESP32 microcontroller is programmed to read pH values and control the water pump based on the readings.

Component List

  1. Pump

    • Description: A generic pump used for water circulation.
    • Pins: +, -
  2. POWER SUPPLY 5V 5AMP

    • Description: Provides 5V DC power with a maximum current of 5A.
    • Pins: 220V Positive Pole (AC), 220V Negative Pole (AC), GND, GND (DC), 12V-24V Output (DC)
  3. XL4015 5A DC Buck Step-down

    • Description: A DC-DC buck converter capable of stepping down voltage with a maximum current of 5A.
    • Pins: Output +, Output -, Input +, Input -
  4. Terminal Block

    • Description: A terminal block for connecting multiple wires.
    • Pins: 1, 2, 3, 4, 5, 6, 7, 8
  5. 12V Relay

    • Description: A relay used to control high-power devices.
    • Pins: NO, COM, NC, IN, DC-, DC+
  6. PH Meter

    • Description: A sensor used to measure the pH level of a solution.
    • Pins: Signal, VCC, GND
  7. L298N DC Motor Driver

    • Description: A motor driver used to control DC motors.
    • 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
  8. Water Pump

    • Description: A generic water pump.
    • Pins: positive, negative
  9. ESP32

    • Description: A microcontroller with built-in Wi-Fi and Bluetooth capabilities.
    • Pins: EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, GND, VIN, 3V3, D15, D2, D4, RX2, TX2, D5, D18, D19, D21, RX0, TX0, D22, D23, BOOT

Wiring Details

Pump

POWER SUPPLY 5V 5AMP

XL4015 5A DC Buck Step-down

Terminal Block

12V Relay

PH Meter

L298N DC Motor Driver

Water Pump

ESP32

Documented Code

ESP32 Code

#define PH_SENSOR_PIN 34  // Pin analog ESP32 (Po terhubung ke sini)

// Variabel pembacaan sensor
float sensorValue;
float voltage;
float pHValue;

// Kalibrasi sensor pH
const float VREF = 3.3;                    // Tegangan referensi ADC ESP32
const float calibration_offset = 0.00;     // Offset kalibrasi (sesuaikan)
const float slope = -5.70;                 // Kemiringan tegangan sensor pH

void setup() {
  Serial.begin(115200);       // Memulai komunikasi serial
  analogReadResolution(12);   // Resolusi 12-bit ADC (0-4095)
  Serial.println("Pembacaan Sensor pH dari Pin Po...");
}

void loop() {
  // Membaca nilai dari pin analog Po
  sensorValue = analogRead(PH_SENSOR_PIN);
  
  // Mengonversi nilai ADC ke tegangan
  voltage = sensorValue * (VREF / 4095.0);
  
  // Menghitung nilai pH berdasarkan tegangan
  pHValue = 7 + ((2.5 - voltage) / slope) + calibration_offset;

  // Menampilkan hasil di serial monitor
  Serial.print("Nilai ADC: ");
  Serial.print(sensorValue);
  Serial.print(" | Tegangan: ");
  Serial.print(voltage, 2);
  Serial.print(" V | Nilai pH: ");
  Serial.println(pHValue, 2);

  delay(1000);  // Delay 1 detik
}

XL4015 5A DC Buck Step-down Code

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

This documentation provides a comprehensive overview of the circuit, including the components used, their wiring details, and the code for the microcontrollers.