Smoke Monitoring System

An Arduino-based project to monitor and detect smoke levels

Project Description

The Smoke Monitoring System is an Arduino-based project designed to detect smoke levels in the environment and provide real-time feedback. Using an MQ-2 smoke sensor, it measures the concentration of smoke or harmful gases in the air. The Arduino Uno processes the readings and displays the results on an OLED display. A buzzer is also included to alert users when smoke levels exceed a predefined safety threshold.

Component List

Component Images

Circuit Diagram

Circuit Diagram

Connections Table

Component
Arduino Pin
MQ-2 A0 --- A0(Analog Pin)
GND --- GND
VCC---5v
OLED Display SDA--- A4
SCL---A5
VCC---5V
GND --- GND
Buzzer Pin 8 (Digital Pin)
GND --- GND

Project Code

// Include required libraries
#include 
#include 
#include 

// OLED display configuration
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

// Pin configuration
const int smokeSensorPin = A1;
const int threshold = 200;
const int buzzerPin = 8;

void setup() {
  Serial.begin(115200);

  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for (;;);
  }

  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0, 0);
  display.println("Smoke Monitoring System");
  display.display();
  delay(3000);

  pinMode(buzzerPin, OUTPUT);
}

void loop() {
  int smokeValue = analogRead(smokeSensorPin);

  display.clearDisplay();
  if (smokeValue >= threshold) {
    display.println("Smoke Detected!");
    digitalWrite(buzzerPin, HIGH);
  } else {
    display.println("You are Safe");
    digitalWrite(buzzerPin, LOW);
  }
  display.display();
  delay(1000);
}