How To Make A Smoke Alarm For Your Kitchen Using Arduino?

Fire security is the most essential parameter of any home, shop or workplace that must be taken care of in the first place. The most common cause of the fire is gas leakage. In this project, we are going to make a smoke alarm for our kitchen using a gas sensor. This sensor will detect the intensity of smoke. If the intensity of smoke exceeds a certain limit, the alarm will switch on to notify a person to take care of that smoke as soon as possible.

How to Make a Smoke Alarm using a Smoke Sensor?

Now as we know the abstract of our project, let us start working on this project.

Step 1: Components Used

The best approach to start any project is to make a complete list of components. This is not only an intelligent way to start a project but it also saves us from many inconveniences in the middle of the project. A list of components of this project is given below:

  • No products found.
  • No products found.
  • Breadboard
  • No products found.
  • No products found.
  • LED
  • No products found.

Step 2: Studying the Components

As we have made a list of components that we are going to use in our project. Let us move a step ahead and go through a brief study of how these components work.

Arduino Nano is a microcontroller board that is used to perform various tasks in different circuits. The microcontroller that Arduino Nano uses is ATmega328P. We burn a C Code on this board to tell it how and what operations to carry out.

Arduino Nano

MQ-2 is the most common Metal Oxide Semiconductor (MOS) type gas sensor. It is very sensitive to smoke and other flammable gases like LPG, Butane, Propane, Methane, Alcohol, Hydrogen, and Carbon Monoxide, etc. When the gas comes in contact, it uses a simple voltage divider network to detect the smoke. When the smoke is detected, its voltage increases. The change in internal resistance depends on the concentration of gas or smoke. It has a small potentiometer that is used to adjust the sensitivity of this sensor.

Working

Step 3: Assembling the components

Now as we know the main idea behind the working of each component. Let us assemble all the components and make a working circuit.

  1. Insert the Arduino Nano and MQ-2 smoke sensor in the breadboard. Power up the sensor through Arduino and connect the A0 pin of the sensor to A5 of Arduino.
  2. Connect a buzzer and an LED in a parallel configuration. Connect their one end to the ground of Arduino and other to the pin D8 of Arduino Nano. Don’t forget to connect a 220-ohm resistor with the LED and buzzer.
Circuit Diagram

Step 4: Getting started with Arduino

If you are not already familiar with the Arduino IDE, don’t worry because a step by step procedure to set-up and use Arduino IDE with a microcontroller board is explained below.

  1. Download the latest version of Arduino IDE from Arduino
  2. Connect your Arduino Nano board to your laptop and open the control panel. in the control panel, click on Hardware and Sound. Now click on Devices and Printers. Here, find the port to which your microcontroller board is connected. In my case it is COM14 but it is different on different computers.
    Finding Port
  3. Click on the Tool menu and set the board to Arduino Nano.
    Setting board
  4. In the same Tool menu, Set the Processor to ATmega328P (Old Bootloader).
    Setting Processor
  5. In the same Tool menu, set the port to the port number that you observed before in the Devices and Printers.
    Setting Port
  6. Download the code attached below and paste it into your Arduino IDE. Click on the upload button to burn the code on your microcontroller board.
    Upload

Download the code by clicking here.

Step 5: Code

The code is pretty well commented and self-explanatory. But still, it is briefly explained below.

1. The pins of Arduino that are connected to the sensor and the buzzer are initialized at the start. The value of the threshold is also set here in a variable named sensorThres.

int buzzer = 8;
int smokePin = A5;
// Your threshold value
int sensorThres = 400;

2. void setup() is a function in which all the pins are set to be used as OUTPUT or INPUT. This function also sets the baud rate of the Arduino Nano. Baud Rate is the speed at which the microcontroller board communicates with other sensors. the command, Serial.begin() sets the baud rate which is mostly 9600. The baud rate can be changed according to our wishes.

void setup() {
pinMode(buzzer, OUTPUT);
pinMode(smokePin, INPUT);
Serial.begin(9600);
}

3. void loop() is a function that runs repeatedly in a loop. In this loop, an analog value from the sensor is being read. This analog value is then compared to the threshold value that we have already set at the start. If this value is greater than the threshold value, the buzzer and led will switch on, otherwise, they will remain switch off.

void loop() {
int analogSensor = analogRead(smokePin);

Serial.print("Pin A0: ");
Serial.println(analogSensor);
// Checks if it has reached the threshold value
if (analogSensor > sensorThres)
{
 digitalWrite(buzzer, HIGH);
}
else
{
 digitalWrite(buzzer, LOW);
}
delay(100);
}

Now as we know how to use a smoke sensor to sense different gases and switch on an alarm to notify anyone nearby, we can make our smoke alarm instead of buying an expensive one from the market because the smoke alarm that we can make at home is low cost and efficient.

ABOUT THE AUTHOR

Hamza Iqbal


Hey! I am Hamza. I am an Electrical Engineer who has a very innovative approach towards daily life stuff. I tend to make life easier by making circuits and designs to automate things around me. I mainly work with printed circuit boards on proteus to bring life to my inventions.