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

Arduino Uno Smoke Detector with I2C Display and Buzzer Alert

View and Edit Project In Cirkit DesignerImage of Arduino Uno Smoke Detector with I2C Display and Buzzer Alert

Circuit Documentation

Summary

This circuit is a smoke detection system using an Arduino Uno R3 microcontroller. It includes an I2C display for visual feedback, multiple LEDs for status indication, a buzzer for audible alerts, and a photocell (LDR) for smoke detection. The system reads the LDR value to detect smoke and adjusts the reference voltage using two switches. When smoke is detected, the system activates the red LED and buzzer, and displays a message on the I2C display.

Component List

  1. Arduino Uno R3

    • Description: Microcontroller board based on the ATmega328P.
    • Pins: D8, D9, D10, D11, D12, D13, GND, AREF, SDA, SCL, D0/RX, D1/Tx, D2, D3, D4, D5, D6, D7, A5/SCL, A4/SDA, A3, A2, A1, A0, Vin, 5V, 3.3V, RESET, IOREF, NONE, USB Jack, Power Jack.
  2. LED: Two Pin (green)

    • Description: Green LED.
    • Pins: cathode, anode.
  3. LED: Two Pin (blue)

    • Description: Blue LED.
    • Pins: cathode, anode.
  4. LED: Two Pin (red)

    • Description: Red LED.
    • Pins: cathode, anode.
  5. Buzzer

    • Description: Buzzer for audible alerts.
    • Pins: GND, IN.
  6. Photocell (LDR)

    • Description: Light-dependent resistor for smoke detection.
    • Pins: pin 0, pin 1.
  7. Resistor (100 Ohms)

    • Description: Resistor with 100 Ohms resistance.
    • Pins: pin1, pin2.
  8. Resistor (150 Ohms)

    • Description: Resistor with 150 Ohms resistance.
    • Pins: pin1, pin2.
  9. I2C DISPLAY

    • Description: I2C display for visual feedback.
    • Pins: GND, VCC, SDL, SCL.

Wiring Details

Arduino Uno R3

LED: Two Pin (green)

LED: Two Pin (blue)

LED: Two Pin (red)

Buzzer

Photocell (LDR)

Resistor (100 Ohms)

Resistor (150 Ohms)

Resistor (150 Ohms)

I2C DISPLAY

Documented Code

#include <LiquidCrystal_I2C_Hangul.h> // Include the library for the display

LiquidCrystal_I2C_Hangul lcd(0x27, 16, 2); // Set the LCD address to 0x27 for a 16 chars and 2 line display

const int ldrPin = A0;     // LDR connected to A0
const int blueLEDPin = 13; // Internal LED for blinking
const int greenLEDPin = 3; // Green LED connected to D3
const int redLEDPin = 4;   // Red LED connected to D4
const int buzzerPin = 5;   // Buzzer connected to D5
const int switch1Pin = 6;  // Switch 1 connected to D6
const int switch2Pin = 7;  // Switch 2 connected to D7

int referenceVoltage = 860; // Initial reference voltage (adjustable)
int ldrValue = 0;

void setup() {
  pinMode(blueLEDPin, OUTPUT);
  pinMode(greenLEDPin, OUTPUT);
  pinMode(redLEDPin, OUTPUT);
  pinMode(buzzerPin, OUTPUT);
  pinMode(switch1Pin, INPUT_PULLUP);
  pinMode(switch2Pin, INPUT_PULLUP);

  lcd.init(); // initialize the lcd
  lcd.begin(16, 2); // Corrected to include the number of columns and rows
  lcd.clear();                 // clear display
  lcd.setCursor(0, 0);         // move cursor to   (0, 0)
  lcd.print("Hello, This is a");
  lcd.setCursor(0, 1);
  lcd.print("Optical Sensor");
  delay(2000);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Smoke Detector");
  lcd.setCursor(0, 1);
  lcd.print("System");
  delay(2000);
  lcd.clear();

  Serial.begin(9600);
}

void loop() {
  // Blink the blue LED
  digitalWrite(blueLEDPin, HIGH);
  delay(500);
  digitalWrite(blueLEDPin, LOW);
  delay(500);

  // Read the LDR value
  ldrValue = analogRead(ldrPin);
  Serial.println(ldrValue);

  // Adjust reference voltage using switches
  if (digitalRead(switch1Pin) == LOW) {
    referenceVoltage += 5;
    delay(100);
  }
  if (digitalRead(switch2Pin) == LOW) {
    referenceVoltage -= 5;
    delay(100);
  }

  // Check if smoke is detected
  if (ldrValue > referenceVoltage) {
    // Smoke detected
    digitalWrite(greenLEDPin, LOW);
    digitalWrite(redLEDPin, HIGH);
    digitalWrite(buzzerPin, HIGH);

    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Smoke Detected");
    lcd.setCursor(0, 1);
    lcd.print(ldrValue);
    delay(2000);
  } else {
    // No smoke detected
    digitalWrite(greenLEDPin, HIGH);
    digitalWrite(redLEDPin, LOW);
    digitalWrite(buzzerPin, LOW);

    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("No Smoke Detected");
    lcd.setCursor(0, 1);
    lcd.print(ldrValue);
    delay(2000);
  }

  delay(200); // Short delay to avoid rapid switching
}

This code initializes the components, reads the LDR value, and adjusts the reference voltage using two switches. It then checks if smoke is detected and updates the LEDs, buzzer, and I2C display accordingly.