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

Arduino UNO Based Multi-Sensor Monitoring System with LCD Feedback and Alert Buzzer

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based Multi-Sensor Monitoring System with LCD Feedback and Alert Buzzer

Circuit Documentation

Summary

This circuit is designed to monitor various environmental parameters including water level, gas presence, distance measurement, and vibration detection. It utilizes an Arduino UNO as the central microcontroller to process inputs from a water level sensor, an MQ-2 gas sensor, an HC-SR04 ultrasonic sensor, and an SW-420 vibration sensor. The circuit provides visual feedback through an LCD Display and audible alerts using a buzzer. The Arduino UNO is also responsible for controlling the power flow to the sensors and the buzzer based on the sensor readings.

Component List

Arduino UNO

Water Level Sensor

SW-420 Vibration Sensor

HC-SR04 Ultrasonic Sensor

MQ-2 Gas Sensor

Buzzer

LCD Display 16x4 I2C

Wiring Details

Arduino UNO

Water Level Sensor

SW-420 Vibration Sensor

HC-SR04 Ultrasonic Sensor

MQ-2 Gas Sensor

Buzzer

LCD Display 16x4 I2C

Documented Code

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

// Initialize the LCD (address 0x27, 16 columns, 2 rows)
LiquidCrystal_I2C lcd(0x27, 16, 2);

const int waterLevelPin = A0; // Water level sensor
const int trigPin = 9;        // HC-SR04 Trig pin
const int echoPin = 10;       // HC-SR04 Echo pin
const int gasSensorPin = A1;  // Gas sensor
const int vibrationSensorPin = 11; // Vibration sensor
const int buzzerPin = 8;      // Buzzer

// Thresholds
const int waterLevelThreshold = 700; // Example threshold for water level
const long distanceThreshold = 20;    // Example threshold for distance in cm
const int gasThreshold = 400;          // Example threshold for gas level

void setup() {
  Serial.begin(9600);
  
  // Initialize the LCD
  lcd.begin(16,2);
  lcd.backlight();
  
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(vibrationSensorPin, INPUT);
  pinMode(buzzerPin, OUTPUT);
  
  // Start buzzer off
  digitalWrite(buzzerPin, LOW);
}

void loop() {
  // Read water level
  int waterLevelValue = analogRead(waterLevelPin);
  
  // Read distance
  long distance = getDistance();
  
  // Read gas level
  int gasLevelValue = analogRead(gasSensorPin);
  
  // Read vibration sensor
  int vibrationState = digitalRead(vibrationSensorPin);
  
  // Clear the LCD
  lcd.clear();
  
  // Display readings
  lcd.setCursor(0, 0);
  lcd.print("WL:");
  lcd.print(waterLevelValue);
  lcd.print("  ");
  
  lcd.setCursor(0, 1);
  lcd.print("Dist:");
  lcd.print(distance);
  lcd.print("cm");

  // Check water level
  if (waterLevelValue > waterLevelThreshold) {
    Serial.println("Water level too high!");
    digitalWrite(buzzerPin, HIGH); // Turn on buzzer
    lcd.setCursor(10, 0);
    lcd.print("!High WL");
  }
  
  // Check distance
  if (distance < distanceThreshold) {
    Serial.println("Object too close!");
    digitalWrite(buzzerPin, HIGH); // Turn on buzzer
    lcd.setCursor(10, 1);
    lcd.print("!Close");
  }
  
  // Check gas level
  if (gasLevelValue > gasThreshold) {
    Serial.println("Gas level too high!");
    digitalWrite(buzzerPin, HIGH); // Turn on buzzer
    lcd.setCursor(10, 0);
    lcd.print("!High Gas");
  }
  
  // Check vibration
  if (vibrationState == HIGH) {
    Serial.println("Vibration detected!");
    digitalWrite(buzzerPin, HIGH); // Turn on buzzer
    lcd.setCursor(10, 1);
    lcd.print("!Vib Det");
  }
  
  // Delay for stability
  delay(500);
  
  // Turn off buzzer if no alerts
  if (waterLevelValue <= waterLevelThreshold && distance >= distanceThreshold && gasLevelValue <= gasThreshold && vibrationState == LOW) {
    digitalWrite(buzzerPin, LOW);
  }
}

// Function to get distance from the ultrasonic sensor
long getDistance() {
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  
  long duration = pulseIn(echoPin, HIGH);
  return duration * 0.034 / 2; // Convert to cm
}

This code is responsible for initializing the sensors and the LCD display, reading sensor data, and providing feedback based on predefined thresholds. It includes functions for reading the water level, gas concentration, distance, and vibration state, and it activates the buzzer and updates the LCD display if any readings exceed the set thresholds.