Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

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

Image 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

  • Microcontroller board based on the ATmega328P
  • Provides digital and analog I/O pins
  • Powers the sensors and reads their outputs
  • Drives the LCD display and buzzer

Water Level Sensor

  • Detects the level of water
  • Outputs an analog signal corresponding to the water level

SW-420 Vibration Sensor

  • Detects vibrations and movements
  • Outputs a digital signal when vibration is detected

HC-SR04 Ultrasonic Sensor

  • Measures distance by emitting ultrasonic waves
  • Outputs a pulse width corresponding to the reflection time

MQ-2 Gas Sensor

  • Detects various gases including LPG, smoke, and alcohol
  • Outputs both analog and digital signals based on gas concentration

Buzzer

  • Emits an audible alert when activated
  • Controlled by a digital output from the Arduino UNO

LCD Display 16x4 I2C

  • Displays text information
  • Uses I2C communication for interfacing with the Arduino UNO

Wiring Details

Arduino UNO

  • 5V and GND pins provide power to all sensors and the LCD display
  • A0 pin connected to the Water Level Sensor signal output
  • A1 pin connected to the MQ-2 Gas Sensor analog output
  • D8 pin controls the buzzer
  • D9 pin connected to the HC-SR04 Ultrasonic Sensor trigger input
  • D10 pin connected to the HC-SR04 Ultrasonic Sensor echo output
  • D11 pin connected to the SW-420 Vibration Sensor digital output
  • A4 (SDA) and A5 (SCL) pins connected to the LCD Display I2C interface

Water Level Sensor

  • SIG pin connected to Arduino UNO A0
  • VCC and GND pins connected to Arduino UNO 5V and GND

SW-420 Vibration Sensor

  • Digital output pin connected to Arduino UNO D11
  • vcc and Ground pins connected to Arduino UNO 5V and GND

HC-SR04 Ultrasonic Sensor

  • TRIG pin connected to Arduino UNO D9
  • ECHO pin connected to Arduino UNO D10
  • VCC and GND pins connected to Arduino UNO 5V and GND

MQ-2 Gas Sensor

  • A0 pin connected to Arduino UNO A1
  • VCC and GND pins connected to Arduino UNO 5V and GND

Buzzer

  • PIN connected to Arduino UNO D8
  • GND connected to Arduino UNO GND

LCD Display 16x4 I2C

  • SDA and SCL pins connected to Arduino UNO A4 and A5
  • VCC and GND pins connected to Arduino UNO 5V and GND

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.