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

Arduino UNO Water Level Sensor with Piezo Buzzer Alert System

View and Edit Project In Cirkit DesignerImage of Arduino UNO Water Level Sensor with Piezo Buzzer Alert System

Circuit Documentation

Summary

This circuit is designed to monitor water levels using a water level sensor and provide audible feedback through a piezo buzzer. The core of the circuit is an Arduino UNO microcontroller, which reads the sensor data and controls the buzzer based on the water level.

Component List

  1. Arduino UNO

    • Description: A 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. Water Level Sensor

    • Description: A sensor used to detect the level of water.
    • Pins: SIG, VCC, GND
  3. Piezo Buzzer

    • Description: An electronic device that produces a sound when a voltage is applied.
    • Pins: pin 1, pin 2
  4. Comment

    • Description: Placeholder for comments in the circuit design.
    • Pins: None

Wiring Details

Arduino UNO

Water Level Sensor

Piezo Buzzer

Code Documentation

// Pin Definitions
const int waterSensorPin = A0;  // Pin connected to the water sensor's signal (S) pin
const int buzzerPin = 3;        // Pin connected to the buzzer

void setup() {
  pinMode(waterSensorPin, INPUT);  // Set the water sensor pin as input
  Serial.begin(9600);              // Start serial communication for debugging
}

void loop() {
  int sensorValue = analogRead(waterSensorPin);  // Read the water sensor value
  Serial.println(sensorValue);  // Print the sensor value to the Serial Monitor for debugging

  // Determine frequency or beep pattern based on sensor value
  if (sensorValue < 630) {
    noTone(buzzerPin);  // Turn off buzzer
  } else if (sensorValue >= 630 && sensorValue < 638) {
    tone(buzzerPin, 200, 500);  // Level 1: Low frequency
    delay(500);
  } else if (sensorValue >= 638 && sensorValue < 646) {
    tone(buzzerPin, 300, 500);  // Level 2
    delay(500);
  } else if (sensorValue >= 646 && sensorValue < 654) {
    tone(buzzerPin, 400, 500);  // Level 3
    delay(500);
  } else if (sensorValue >= 654 && sensorValue < 662) {
    tone(buzzerPin, 500, 500);  // Level 4
    delay(500);
  } else if (sensorValue >= 662 && sensorValue < 670) {
    tone(buzzerPin, 600, 400);  // Level 5: Faster beeps
    delay(400);
  } else if (sensorValue >= 670 && sensorValue < 678) {
    tone(buzzerPin, 700, 400);  // Level 6
    delay(400);
  } else if (sensorValue >= 678 && sensorValue < 686) {
    tone(buzzerPin, 800, 300);  // Level 7
    delay(300);
  } else if (sensorValue >= 686 && sensorValue < 694) {
    tone(buzzerPin, 900, 300);  // Level 8
    delay(300);
  } else if (sensorValue >= 694 && sensorValue < 702) {
    tone(buzzerPin, 1000, 300); // Level 9
    delay(300);
  } else if (sensorValue >= 702 && sensorValue < 710) {
    tone(buzzerPin, 1100, 200); // Level 10: Higher pitch, faster beeps
    delay(200);
  } else if (sensorValue >= 710 && sensorValue < 718) {
    tone(buzzerPin, 1200, 200); // Level 11
    delay(200);
  } else if (sensorValue >= 718 && sensorValue < 726) {
    tone(buzzerPin, 1300, 150); // Level 12
    delay(150);
  } else if (sensorValue >= 726 && sensorValue < 734) {
    tone(buzzerPin, 1400, 150); // Level 13
    delay(150);
  } else if (sensorValue >= 734 && sensorValue < 742) {
    tone(buzzerPin, 1500, 100); // Level 14
    delay(100);
  } else if (sensorValue >= 742 && sensorValue < 750) {
    tone(buzzerPin, 1600, 100); // Level 15
    delay(100);
  } else {
    tone(buzzerPin, 2000, 100); // Level 16: Maximum frequency, very fast
    delay(100);
  }
}

This code reads the water level sensor value and adjusts the buzzer's tone and frequency based on the sensor reading. The higher the water level, the higher the frequency and the faster the beeps from the buzzer.