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

Arduino UNO Vape Detection System with LCD Display and Fan Control

View and Edit Project In Cirkit DesignerImage of Arduino UNO Vape Detection System with LCD Display and Fan Control

Circuit Documentation

Summary

This circuit is designed to detect smoke using an MQ2 sensor and respond by activating a fan and a buzzer. The system also includes an LCD display to show the smoke level and status. The Arduino UNO microcontroller is used to control the components and process the sensor data.

Component List

  1. Arduino UNO

    • Description: 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. 5V Relay

    • Description: Relay module to control high voltage devices.
    • Pins: Normally Open, Common terminal, Normally Closed, In, GND, VCC
  3. Micro USB to Cable (2 Pin)

    • Description: Provides power to the circuit.
    • Pins: Micro USB, +, -
  4. 16x2 I2C LCD

    • Description: LCD display with I2C interface.
    • Pins: GND, VCC, SDA, SCL
  5. LED: Two Pin (red)

    • Description: Red LED.
    • Pins: cathode, anode
  6. LED: Two Pin (green)

    • Description: Green LED.
    • Pins: cathode, anode
  7. MQ2

    • Description: Gas sensor to detect smoke.
    • Pins: VCC, GND, AOUT, DOUT
  8. Fan

    • Description: Cooling fan.
    • Pins: GND, 5V
  9. Buzzer

    • Description: Buzzer for audio alert.
    • Pins: PIN, GND
  10. Resistor (200 Ohms)

    • Description: Resistor with 200 Ohms resistance.
    • Pins: pin1, pin2
  11. Resistor (220 Ohms)

    • Description: Resistor with 220 Ohms resistance.
    • Pins: pin1, pin2

Wiring Details

Arduino UNO

5V Relay

Micro USB to Cable (2 Pin)

16x2 I2C LCD

MQ2

Fan

Buzzer

LED: Two Pin (red)

LED: Two Pin (green)

Resistor (200 Ohms)

Resistor (220 Ohms)

Code Documentation

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

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

// Pin Definitions
const int mq2AoutPin = A0;    // MQ2 analog output pin
const int relayPin = 8;       // Relay module control pin
const int buzzerPin = 9;      // Buzzer pin
const int smokeThreshold = 300; // Smoke threshold (adjust based on testing)

void setup() {
  // Initialize LCD
  lcd.init();
  lcd.backlight();

  // Pin Modes
  pinMode(mq2AoutPin, INPUT);
  pinMode(relayPin, OUTPUT);
  pinMode(buzzerPin, OUTPUT);

  // Initial States
  digitalWrite(relayPin, LOW); // Fan off
  digitalWrite(buzzerPin, LOW); // Buzzer off

  // Display Initial Message
  lcd.setCursor(0, 0);
  lcd.print("Vape Detection");
  lcd.setCursor(0, 1);
  lcd.print("Initializing...");
  delay(2000);
  lcd.clear();
}

void loop() {
  // Read the analog value from MQ2
  int smokeValue = analogRead(mq2AoutPin);

  // Display smoke level on LCD
  lcd.setCursor(0, 0);
  lcd.print("Smoke Level: ");
  lcd.print(smokeValue);

  // Check smoke threshold
  if (smokeValue > smokeThreshold) {
    // Smoke detected
    lcd.setCursor(0, 1);
    lcd.print("Status: ALERT!");
    digitalWrite(relayPin, HIGH); // Turn on fan
    digitalWrite(buzzerPin, HIGH); // Activate buzzer
  } else {
    // No smoke detected
    lcd.setCursor(0, 1);
    lcd.print("Status: Safe  ");
    digitalWrite(relayPin, LOW); // Turn off fan
    digitalWrite(buzzerPin, LOW); // Deactivate buzzer
  }

  // Add a short delay to avoid rapid fluctuations
  delay(500);
}

This code initializes the LCD, sets up the pin modes, and continuously reads the smoke level from the MQ2 sensor. If the smoke level exceeds the threshold, it activates the fan and buzzer and displays an alert message on the LCD. If the smoke level is below the threshold, it deactivates the fan and buzzer and displays a safe status on the LCD.